tracking_number 0.10.5 → 3.0.0

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.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +2 -0
  3. data/.github/dependabot.yml +22 -0
  4. data/.github/workflows/release.yml +36 -0
  5. data/.github/workflows/ruby.yml +35 -0
  6. data/.gitmodules +3 -0
  7. data/.tool-versions +1 -0
  8. data/CHANGELOG.md +318 -0
  9. data/Gemfile +4 -2
  10. data/README.md +112 -15
  11. data/Rakefile +4 -1
  12. data/bin/console +14 -0
  13. data/lib/data/couriers/amazon.json +45 -0
  14. data/lib/data/couriers/canadapost.json +33 -0
  15. data/lib/data/couriers/canpar.json +29 -0
  16. data/lib/data/couriers/dhl.json +97 -0
  17. data/lib/data/couriers/dpd.json +345 -0
  18. data/lib/data/couriers/fedex.json +291 -0
  19. data/lib/data/couriers/gofo.json +24 -0
  20. data/lib/data/couriers/landmark.json +26 -0
  21. data/lib/data/couriers/lasership.json +105 -0
  22. data/lib/data/couriers/old_dominion.json +65 -0
  23. data/lib/data/couriers/ontrac.json +74 -0
  24. data/lib/data/couriers/purolator.json +50 -0
  25. data/lib/data/couriers/s10.json +1443 -0
  26. data/lib/data/couriers/speedee.json +26 -0
  27. data/lib/data/couriers/ups.json +197 -0
  28. data/lib/data/couriers/usps.json +272 -0
  29. data/lib/data/couriers/yodel.json +29 -0
  30. data/lib/data/couriers/yunexpress.json +25 -0
  31. data/lib/tracking_number/active_model_validator.rb +1 -1
  32. data/lib/tracking_number/base.rb +291 -22
  33. data/lib/tracking_number/checksum_validations.rb +119 -0
  34. data/lib/tracking_number/info.rb +26 -0
  35. data/lib/tracking_number/loader.rb +82 -0
  36. data/lib/tracking_number/partnership.rb +7 -0
  37. data/lib/tracking_number/unknown.rb +45 -0
  38. data/lib/tracking_number/version.rb +1 -1
  39. data/lib/tracking_number.rb +69 -17
  40. data/package.json +77 -0
  41. data/test/partnership_test.rb +71 -0
  42. data/test/renamed_types_test.rb +44 -0
  43. data/test/test_helper.rb +14 -7
  44. data/test/tracking_number_meta_test.rb +145 -0
  45. data/test/tracking_number_test.rb +191 -0
  46. data/tracking_number.gemspec +53 -22
  47. data/yarn.lock +3425 -0
  48. metadata +131 -46
  49. data/.travis.yml +0 -12
  50. data/VERSION +0 -1
  51. data/lib/tracking_number/dhl.rb +0 -34
  52. data/lib/tracking_number/fedex.rb +0 -156
  53. data/lib/tracking_number/ontrac.rb +0 -34
  54. data/lib/tracking_number/ups.rb +0 -108
  55. data/lib/tracking_number/usps.rb +0 -166
  56. data/test/dhl_tracking_number_test.rb +0 -35
  57. data/test/fedex_tracking_number_test.rb +0 -75
  58. data/test/ontrac_tracking_number_test.rb +0 -24
  59. data/test/ups_tracking_number_test.rb +0 -36
  60. data/test/usps_tracking_number_test.rb +0 -73
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "Spee-Dee Delivery",
3
+ "courier_code": "speedee",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "Spee-Dee (20)",
7
+ "id": "speedee",
8
+ "regex": "\\s*S\\s*P\\s*(?<SerialNumber>([0-9]\\s*){18})\\s*",
9
+ "validation": {},
10
+ "tracking_url": "https://www.speedeedelivery.com/track/?tracking=%s",
11
+ "test_numbers": {
12
+ "valid": [
13
+ "SP029692510000920746",
14
+ "SP029692510000901479",
15
+ "SP029692510000688332",
16
+ "SP029692510000279301",
17
+ "SP029692450001607639"
18
+ ],
19
+ "invalid": [
20
+ "029692510000920746",
21
+ "SX029692510000920746"
22
+ ]
23
+ }
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,197 @@
1
+ {
2
+ "name": "UPS",
3
+ "courier_code": "ups",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "UPS",
7
+ "id": "ups",
8
+ "regex": [
9
+ "\\s*1\\s*Z\\s*(?<SerialNumber>",
10
+ "(?<ShipperId>(?:[A-Z0-9]\\s*){6,6})",
11
+ "(?<ServiceType>(?:[A-Z0-9]\\s*){2,2})",
12
+ "(?<PackageId>(?:[A-Z0-9]\\s*){7,7}))",
13
+ "(?<CheckDigit>[0-9]\\s*)"
14
+ ],
15
+ "validation": {
16
+ "checksum": {
17
+ "name": "mod10",
18
+ "modulo": 10,
19
+ "evens_multiplier": 1,
20
+ "odds_multiplier": 2,
21
+ "reverse": false
22
+ }
23
+ },
24
+ "tracking_url": "https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=%s",
25
+ "additional": [
26
+ {
27
+ "name": "Service Type",
28
+ "regex_group_name": "ServiceType",
29
+ "lookup": [
30
+ {
31
+ "matches": "01",
32
+ "name": "UPS United States Next Day Air (Red)"
33
+ },
34
+ {
35
+ "matches": "02",
36
+ "name": "UPS United States Second Day Air (Blue)"
37
+ },
38
+ {
39
+ "matches": "03",
40
+ "name": "UPS United States Ground"
41
+ },
42
+ {
43
+ "matches": "12",
44
+ "name": "UPS United States Third Day Select"
45
+ },
46
+ {
47
+ "matches": "13",
48
+ "name": "UPS United States Next Day Air Saver (Red Saver)"
49
+ },
50
+ {
51
+ "matches": "15",
52
+ "name": "UPS United States Next Day Air Early A.M."
53
+ },
54
+ {
55
+ "matches": "22",
56
+ "name": "UPS United States Ground - Returns Plus - Three Pickup Attempts"
57
+ },
58
+ {
59
+ "matches": "32",
60
+ "name": "UPS United States Next Day Air Early A.M. - COD"
61
+ },
62
+ {
63
+ "matches": "33",
64
+ "name": "UPS United States Next Day Air Early A.M. - Saturday Delivery, COD"
65
+ },
66
+ {
67
+ "matches": "41",
68
+ "name": "UPS United States Next Day Air Early A.M. - Saturday Delivery"
69
+ },
70
+ {
71
+ "matches": "42",
72
+ "name": "UPS United States Ground - Signature Required"
73
+ },
74
+ {
75
+ "matches": "44",
76
+ "name": "UPS United States Next Day Air - Saturday Delivery"
77
+ },
78
+ {
79
+ "matches": "66",
80
+ "name": "UPS United States Worldwide Express"
81
+ },
82
+ {
83
+ "matches": "72",
84
+ "name": "UPS United States Ground - Collect on Delivery"
85
+ },
86
+ {
87
+ "matches": "78",
88
+ "name": "UPS United States Ground - Returns Plus - One Pickup Attempt"
89
+ },
90
+ {
91
+ "matches": "90",
92
+ "name": "UPS United States Ground - Returns - UPS Prints and Mails Label"
93
+ },
94
+ {
95
+ "matches": "A0",
96
+ "name": "UPS United States Next Day Air Early A.M. - Adult Signature Required"
97
+ },
98
+ {
99
+ "matches": "A1",
100
+ "name": "UPS United States Next Day Air Early A.M. - Saturday Delivery, Adult Signature Required"
101
+ },
102
+ {
103
+ "matches": "A2",
104
+ "name": "UPS United States Next Day Air - Adult Signature Required"
105
+ },
106
+ {
107
+ "matches": "A8",
108
+ "name": "UPS United States Ground - Adult Signature Required"
109
+ },
110
+ {
111
+ "matches": "A9",
112
+ "name": "UPS United States Next Day Air Early A.M. - Adult Signature Required, COD"
113
+ },
114
+ {
115
+ "matches": "AA",
116
+ "name": "UPS United States Next Day Air Early A.M. - Saturday Delivery, Adult Signature Required, COD"
117
+ },
118
+ {
119
+ "matches": "YW",
120
+ "name": "UPS SurePost - Delivered by the USPS"
121
+ }
122
+ ]
123
+ }
124
+ ],
125
+ "test_numbers": {
126
+ "valid": [
127
+ "1Z5R89390357567127",
128
+ "1Z879E930346834440",
129
+ "1Z410E7W0392751591",
130
+ "1Z8V92A70367203024",
131
+ " 1 Z 8 V 9 2 A 7 0 3 6 7 2 0 3 0 2 4 ",
132
+ "1ZXX3150YW44070023"
133
+ ],
134
+ "invalid": [
135
+ "2Z5R89390357567127",
136
+ "1A5R89390357567127",
137
+ "1Z1111111111111111"
138
+ ]
139
+ }
140
+ },
141
+ {
142
+ "name": "UPS Waybill",
143
+ "regex": [
144
+ "\\s*(?<ServiceType>([AHJKTV]\\s*){1})",
145
+ "(?<SerialNumber>(?:[0-9]\\s*){9})",
146
+ "(?<CheckDigit>[0-9]\\s*){1}"
147
+ ],
148
+ "validation": {
149
+ "checksum": {
150
+ "name": "mod10",
151
+ "modulo": 10,
152
+ "evens_multiplier": 1,
153
+ "odds_multiplier": 2,
154
+ "reverse": false
155
+ }
156
+ },
157
+ "additional": [
158
+ {
159
+ "name": "Service Type",
160
+ "regex_group_name": "ServiceType",
161
+ "lookup": [
162
+ {
163
+ "matches": "J",
164
+ "name": "UPS Next Day Express"
165
+ },
166
+ {
167
+ "matches": "K",
168
+ "name": "UPS Ground"
169
+ },
170
+ {
171
+ "matches": "V",
172
+ "name": "UPS WorldWide Express Saver"
173
+ }
174
+ ]
175
+ }
176
+ ],
177
+ "tracking_url": "https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=%s",
178
+ "test_numbers": {
179
+ "valid": [
180
+ "K1506235620",
181
+ "K 150 623 562 0",
182
+ "K2479825491",
183
+ "J4603636537",
184
+ "V0490119172",
185
+ "V0431105627"
186
+ ],
187
+ "invalid": [
188
+ "K1506235622",
189
+ "K2479825492",
190
+ "J4603636538",
191
+ "V0411335627",
192
+ "V0423305841"
193
+ ]
194
+ }
195
+ }
196
+ ]
197
+ }
@@ -0,0 +1,272 @@
1
+ {
2
+ "name": "United States Postal Service",
3
+ "courier_code": "usps",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "USPS 20",
7
+ "id": "usps_20",
8
+ "description": "Delivery and Signature Confirmation numbers, printed without the application identifier",
9
+ "tracking_url": "https://tools.usps.com/go/TrackConfirmAction?tLabels=%s",
10
+ "regex": [
11
+ "\\s*(?<SerialNumber>",
12
+ "(?<ServiceType>([0-9]\\s*){2})",
13
+ "(?<ShipperId>([0-9]\\s*){9})",
14
+ "(?<PackageId>([0-9]\\s*){8})",
15
+ ")",
16
+ "(?<CheckDigit>[0-9]\\s*)"
17
+ ],
18
+ "validation": {
19
+ "checksum": {
20
+ "name": "mod10",
21
+ "modulo": 10,
22
+ "evens_multiplier": 3,
23
+ "odds_multiplier": 1,
24
+ "reverse": false
25
+ }
26
+ },
27
+ "test_numbers": {
28
+ "valid": [
29
+ "0307 1790 0005 2348 3741",
30
+ " 0 3 0 7 1 7 9 0 0 0 0 5 2 3 4 8 3 7 4 1 ",
31
+ "7112 3456 7891 2345 6787"
32
+ ],
33
+ "invalid": [
34
+ "0307 1790 0005 2348 3742"
35
+ ]
36
+ },
37
+ "additional": [
38
+ {
39
+ "name": "Service Type",
40
+ "regex_group_name": "ServiceType",
41
+ "lookup": [
42
+ { "matches": "01", "name": "Delivery Confirmation", "description": "Priority Mail or First-Class Mail Parcels" },
43
+ { "matches": "02", "name": "Delivery Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels" },
44
+ { "matches_regex": "0[34]", "name": "Delivery Confirmation", "description": "Retail" },
45
+ { "matches": "05", "name": "Delivery Confirmation", "description": "Priority Mail or First-Class Mail Parcels, insured over $50" },
46
+ { "matches": "06", "name": "Delivery Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels, insured over $50" },
47
+ { "matches": "07", "name": "Delivery Confirmation", "description": "Priority Mail, insured $50 or under" },
48
+ { "matches": "08", "name": "Delivery Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels, insured $50 or under" },
49
+ { "matches": "14", "name": "Delivery Confirmation", "description": "Software vendors only, by approval" },
50
+ { "matches": "21", "name": "Signature Confirmation", "description": "Priority Mail or First-Class Mail Parcels" },
51
+ { "matches": "22", "name": "Signature Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels" },
52
+ { "matches_regex": "2[34]", "name": "Signature Confirmation", "description": "Retail" },
53
+ { "matches": "25", "name": "Signature Confirmation", "description": "Priority Mail or First-Class Mail Parcels, insured, all values" },
54
+ { "matches": "26", "name": "Signature Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels, insured, all values" },
55
+ { "matches": "34", "name": "Signature Confirmation", "description": "Software vendors only, by approval" },
56
+ { "matches": "50", "name": "Electronic File Header", "description": "Used in the file header record only, never on a package" },
57
+ { "matches": "56", "name": "Passive Enroute Scan", "description": "A free scan as the parcel passes through a sorting plant, with no confirmation service attached" },
58
+ { "matches": "73", "name": "Insured Mail", "description": "Insured only, value over $50" },
59
+ { "matches": "82", "name": "Merchandise Return", "description": "With Delivery Confirmation" },
60
+ { "matches": "83", "name": "Merchandise Return", "description": "With Delivery Confirmation, insured value $50 or under" },
61
+ { "matches": "85", "name": "Merchandise Return", "description": "With Delivery Confirmation, insured value over $50" }
62
+ ]
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ "name": "USPS IMpb N",
68
+ "id": "usps_impb_n",
69
+ "description": "IMpb constructs N01 through N10, issued online or by a vendor or meter",
70
+ "glossary": {
71
+ "ShipperId": { "description": "The company that holds the postal permit the package was mailed under, which Publication 199 calls the Mailer ID. Nine digits when it starts with 9, six otherwise." }
72
+ },
73
+ "tracking_url": "https://tools.usps.com/go/TrackConfirmAction?tLabels=%s",
74
+ "regex": [
75
+ "\\s*((?<RoutingApplicationId>4\\s*2\\s*0\\s*)(?<DestinationZip>([0-9]\\s*){5}(?=([0-9]\\s*){22}(?![0-9])|([0-9]\\s*){26}(?![0-9])))(?<DestinationZipPlus4>([0-9]\\s*){4}(?=([0-9]\\s*){22}(?![0-9])))?)?",
76
+ "(?<SerialNumber>",
77
+ "(?<ApplicationIdentifier>9\\s*4\\s*)",
78
+ "(?<ServiceType>([0-9]\\s*){3})",
79
+ "(?=9\\s*([0-9]\\s*){8}(([0-9]\\s*){15}|([0-9]\\s*){11}|([0-9]\\s*){7})[0-9]\\s*(?![0-9])",
80
+ "|[0-8]\\s*([0-9]\\s*){5}(([0-9]\\s*){14}|([0-9]\\s*){10})[0-9]\\s*(?![0-9]))",
81
+ "(?<ShipperId>9\\s*([0-9]\\s*){8}|[0-8]\\s*([0-9]\\s*){5})",
82
+ "(?<PackageId>([0-9]\\s*){15}|([0-9]\\s*){14}|([0-9]\\s*){11}|([0-9]\\s*){10}|([0-9]\\s*){7})",
83
+ ")",
84
+ "(?<CheckDigit>[0-9]\\s*)"
85
+ ],
86
+ "validation": {
87
+ "checksum": {
88
+ "name": "mod10",
89
+ "modulo": 10,
90
+ "evens_multiplier": 3,
91
+ "odds_multiplier": 1,
92
+ "reverse": true
93
+ }
94
+ },
95
+ "test_numbers": {
96
+ "valid": [
97
+ "420787459400111206206406260787",
98
+ "9400111206206406260787",
99
+ "9400 1112 0108 0805 4830 16",
100
+ "9405803699300124287899",
101
+ "9434611206206406227577",
102
+ "9434611206206407667136",
103
+ "9400111206206407628746",
104
+ "9400111206206407628845"
105
+ ],
106
+ "invalid": [
107
+ "9434611206206407667131",
108
+ "9434611306206407667222",
109
+ "2334611306206407667222"
110
+ ]
111
+ },
112
+ "additional": [
113
+ {
114
+ "name": "Application Identifier",
115
+ "regex_group_name": "ApplicationIdentifier",
116
+ "lookup": [
117
+ { "matches": "94", "name": "Online or vendor label", "description": "Issued through USPS WebTools, or an authorized PC Postage provider" }
118
+ ]
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ "name": "USPS Legacy",
124
+ "id": "usps_legacy",
125
+ "description": "Delivery and Signature Confirmation numbers, carrying the 91 application identifier",
126
+ "glossary": {
127
+ "ApplicationIdentifier": { "description": "Present only when the barcode is UCC/EAN Code 128." }
128
+ },
129
+ "regex": [
130
+ "\\s*(?:(?<RoutingApplicationId>4\\s*2\\s*0\\s*)(?<DestinationZip>([0-9]\\s*){5})(?<DestinationZipPlus4>([0-9]\\s*){4})?)?",
131
+ "(?<SerialNumber>",
132
+ "(?<ApplicationIdentifier>9\\s*1\\s*)?",
133
+ "(?<ServiceType>([0-9]\\s*){2})",
134
+ "(?<ShipperId>([0-9]\\s*){9})",
135
+ "(?<PackageId>([0-9]\\s*){8})",
136
+ ")",
137
+ "(?<CheckDigit>[0-9]\\s*)"
138
+ ],
139
+ "validation": {
140
+ "checksum": {
141
+ "name": "mod10",
142
+ "modulo": 10,
143
+ "evens_multiplier": 3,
144
+ "odds_multiplier": 1,
145
+ "reverse": false
146
+ },
147
+ "serial_number_format": {
148
+ "prepend_if": {
149
+ "matches_regex": "^(?!9\\s*1).+",
150
+ "content": "91"
151
+ }
152
+ }
153
+ },
154
+ "tracking_url": "https://tools.usps.com/go/TrackConfirmAction?tLabels=%s",
155
+ "test_numbers": {
156
+ "valid": [
157
+ "420 22153 9101026837331000039521",
158
+ "9101 1234 5678 9000 0000 13",
159
+ "7196 9010 7560 0307 7385"
160
+ ],
161
+ "invalid": [
162
+ "9101 1234 5678 9000 0000 14",
163
+ "7196 9010 7560 0307 7386"
164
+ ]
165
+ },
166
+ "additional": [
167
+ {
168
+ "name": "Service Type",
169
+ "regex_group_name": "ServiceType",
170
+ "lookup": [
171
+ { "matches": "01", "name": "Delivery Confirmation", "description": "Priority Mail or First-Class Mail Parcels" },
172
+ { "matches": "02", "name": "Delivery Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels" },
173
+ { "matches_regex": "0[34]", "name": "Delivery Confirmation", "description": "Retail" },
174
+ { "matches": "05", "name": "Delivery Confirmation", "description": "Priority Mail or First-Class Mail Parcels, insured over $50" },
175
+ { "matches": "06", "name": "Delivery Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels, insured over $50" },
176
+ { "matches": "07", "name": "Delivery Confirmation", "description": "Priority Mail, insured $50 or under" },
177
+ { "matches": "08", "name": "Delivery Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels, insured $50 or under" },
178
+ { "matches": "14", "name": "Delivery Confirmation", "description": "Software vendors only, by approval" },
179
+ { "matches": "21", "name": "Signature Confirmation", "description": "Priority Mail or First-Class Mail Parcels" },
180
+ { "matches": "22", "name": "Signature Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels" },
181
+ { "matches_regex": "2[34]", "name": "Signature Confirmation", "description": "Retail" },
182
+ { "matches": "25", "name": "Signature Confirmation", "description": "Priority Mail or First-Class Mail Parcels, insured, all values" },
183
+ { "matches": "26", "name": "Signature Confirmation", "description": "Package Services, Parcel Select or Standard Mail Parcels, insured, all values" },
184
+ { "matches": "34", "name": "Signature Confirmation", "description": "Software vendors only, by approval" },
185
+ { "matches": "50", "name": "Electronic File Header", "description": "Used in the file header record only, never on a package" },
186
+ { "matches": "56", "name": "Passive Enroute Scan", "description": "A free scan as the parcel passes through a sorting plant, with no confirmation service attached" },
187
+ { "matches": "73", "name": "Insured Mail", "description": "Insured only, value over $50" },
188
+ { "matches": "82", "name": "Merchandise Return", "description": "With Delivery Confirmation" },
189
+ { "matches": "83", "name": "Merchandise Return", "description": "With Delivery Confirmation, insured value $50 or under" },
190
+ { "matches": "85", "name": "Merchandise Return", "description": "With Delivery Confirmation, insured value over $50" }
191
+ ]
192
+ }
193
+ ]
194
+ },
195
+ {
196
+ "name": "USPS IMpb C",
197
+ "id": "usps_impb_c",
198
+ "description": "IMpb constructs C01 through C10, plus USPS retail",
199
+ "glossary": {
200
+ "ShipperId": { "description": "The company that holds the postal permit the package was mailed under, which Publication 199 calls the Mailer ID. Nine digits when it starts with 9, six otherwise." }
201
+ },
202
+ "regex": [
203
+ "\\s*(?:(?<RoutingApplicationId>4\\s*2\\s*0\\s*)(?<DestinationZip>([0-9]\\s*){5})(?<DestinationZipPlus4>([0-9]\\s*){4}(?=([0-9]\\s*){22}(?![0-9])))?)?",
204
+ "(?<SerialNumber>",
205
+ "(?<ApplicationIdentifier>9\\s*2\\s*(?=([0-9]\\s*){3}9)|9\\s*3\\s*(?=([0-9]\\s*){3}[0-8])|9\\s*5\\s*)",
206
+ "(?<ServiceType>([0-9]\\s*){3})",
207
+ "(?=9\\s*([0-9]\\s*){8}(([0-9]\\s*){11}|([0-9]\\s*){7})[0-9]\\s*(?![0-9])",
208
+ "|[0-8]\\s*([0-9]\\s*){5}(([0-9]\\s*){14}|([0-9]\\s*){10})[0-9]\\s*(?![0-9]))",
209
+ "(?<ShipperId>9\\s*([0-9]\\s*){8}|[0-8]\\s*([0-9]\\s*){5})",
210
+ "(?<PackageId>([0-9]\\s*){14}|([0-9]\\s*){11}|([0-9]\\s*){10}|([0-9]\\s*){7})",
211
+ ")",
212
+ "(?<CheckDigit>[0-9]\\s*)"
213
+ ],
214
+ "validation": {
215
+ "checksum": {
216
+ "name": "mod10",
217
+ "modulo": 10,
218
+ "evens_multiplier": 3,
219
+ "odds_multiplier": 1,
220
+ "reverse": false
221
+ }
222
+ },
223
+ "tracking_url": "https://tools.usps.com/go/TrackConfirmAction?tLabels=%s",
224
+ "test_numbers": {
225
+ "valid": [
226
+ "4201002334249200190132607600833457",
227
+ "4201028200009261290113185417468510",
228
+ " 4 2 0 1 0 2 8 2 0 0 0 0 9 2 6 1 2 9 0 1 1 3 1 8 5 4 1 7 4 6 8 5 1 0 ",
229
+ "9505 5110 6960 5048 6006 24",
230
+ "92748931507708513018050063",
231
+ "92001903060085300042901077",
232
+ "9361 2898 7870 0317 6337 95",
233
+ "9261292700768711948021",
234
+ "420 11213 92 6129098349792366623 8",
235
+ "92 6129098349792366623 8",
236
+ "420902459261290336128704042634",
237
+ "420941179261290336128704062441",
238
+ "420926029261290336128704067248",
239
+ "420902729261290336128704124163",
240
+ "420950549261290336128704133837",
241
+ "420193809261290336128704280838",
242
+ "420900469261290336128704216936"
243
+ ],
244
+ "invalid": [
245
+ "61299998820821171811",
246
+ "9200000000000000000000",
247
+ "420000000000000000000000000000",
248
+ "420000009200000000000000000000",
249
+ "4201028200009261290113185417468511"
250
+ ]
251
+ },
252
+ "additional": [
253
+ {
254
+ "name": "Service Type",
255
+ "regex_group_name": "ServiceType",
256
+ "lookup": [
257
+ { "matches": "612", "name": "Parcel Select" }
258
+ ]
259
+ },
260
+ {
261
+ "name": "Application Identifier",
262
+ "regex_group_name": "ApplicationIdentifier",
263
+ "lookup": [
264
+ { "matches": "92", "name": "Commercial mailer", "description": "Nine digit mailer ID, and may have been carried by another company before USPS" },
265
+ { "matches": "93", "name": "Commercial mailer", "description": "Six digit mailer ID, and may have been carried by another company before USPS" },
266
+ { "matches": "95", "name": "USPS Retail", "description": "Issued at a post office counter, an automated postal center, or a self-service kiosk" }
267
+ ]
268
+ }
269
+ ]
270
+ }
271
+ ]
272
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "Yodel",
3
+ "courier_code": "yodel",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "Yodel",
7
+ "id": "yodel",
8
+ "description": "Yodel's UK domestic numbers, carried on a JD or JJD prefix. Numbers entering the Yodel network from other carriers can take other formats.",
9
+ "regex": [
10
+ "\\s*J\\s*(J\\s*)?D\\s*(?<SerialNumber>([0-9]\\s*){16})\\s*"
11
+ ],
12
+ "validation": {},
13
+ "tracking_url": "https://www.yodel.co.uk/tracking/%s",
14
+ "test_numbers": {
15
+ "valid": [
16
+ "JJD0002257639032011",
17
+ "JJD0002255380054291",
18
+ "JD0002242617644732",
19
+ "JD0002254405060992",
20
+ "J J D 0 0 0 2 2 5 7 6 3 9 0 3 2 0 2 0"
21
+ ],
22
+ "invalid": [
23
+ "JD000225440506099",
24
+ "JC0002254405060992"
25
+ ]
26
+ }
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "YunExpress",
3
+ "courier_code": "yunexpress",
4
+ "tracking_numbers": [
5
+ {
6
+ "name": "YunExpress",
7
+ "id": "yunexpress",
8
+ "tracking_url": "https://www.yuntrack.com/parcelTracking?id=%s",
9
+ "regex": [
10
+ "\\s*Y\\s*T\\s*(?<SerialNumber>([0-9]\\s*){16})\\s*"
11
+ ],
12
+ "validation": {},
13
+ "test_numbers": {
14
+ "valid": [
15
+ "YT2229521272164446",
16
+ "YT2229521272164447",
17
+ " Y T 2 2 2 9 5 2 1 2 7 2 1 6 4 4 4 7 "
18
+ ],
19
+ "invalid": [
20
+ "YT123456789012345"
21
+ ]
22
+ }
23
+ }
24
+ ]
25
+ }
@@ -6,7 +6,7 @@ class TrackingNumberValidator < ActiveModel::EachValidator
6
6
  elsif TrackingNumber.new(value).valid?
7
7
  # looks good to me
8
8
  else
9
- record.errors[attribute] << (options[:message] || 'is not a valid tracking number')
9
+ record.errors.add(attribute, options[:message] || 'is not a valid tracking number')
10
10
  end
11
11
  end
12
12
  end