-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshipping_carriers.cfc
123 lines (82 loc) · 3.02 KB
/
shipping_carriers.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
component {
/**
* Name of the shipper USPS, UPS or FedEx
* @trackingNumber the tracking number you wish to find the shipper name of
*/
public function getShipperName(required string trackingNumber) {
if ( isUSPS(trackingNumber=arguments.trackingNumber).success ) {
return {
'success': true,
'data': isUSPS(trackingNumber=arguments.trackingNumber).data,
'msg': isUSPS(trackingNumber=arguments.trackingNumber).msg
};
} else if ( isUPS(trackingNumber=arguments.trackingNumber).success ) {
return {
'success': true,
'data': isUPS(trackingNumber=arguments.trackingNumber).data,
'msg': isUPS(trackingNumber=arguments.trackingNumber).msg
};
} else if ( isFedEX(trackingNumber=arguments.trackingNumber).success ) {
return {
'success': true,
'data': isFedEX(trackingNumber=arguments.trackingNumber).data,
'msg': isFedEX(trackingNumber=arguments.trackingNumber).msg
};
} else {
return {
'success': false
};
}
}
/**
* Check if tracking number is USPS
* @trackingNumber the tracking number you wish to find the shipper name of
*/
public function isUSPS(required string trackingNumber) {
if ( reFindNoCase('^(94|93|92|94|95)[0-9]{20}$|^(94|93|92|94|95)[0-9]{22}$|^(70|14|23|03)[0-9]{14}$|^(M0|82)[0-9]{8}$|^([A-Z]{2})[0-9]{9}([A-Z]{2})$',arguments.trackingNumber,'true') ) {
return {
'success': true,
'data': 'USPS',
'msg': 'This is a USPS tracking number.'
};
} else {
return {
'success': false
};
}
}
/**
* Check if tracking number is UPS
* @trackingNumber the tracking number you wish to find the shipper name of
*/
public function isUPS(required string trackingNumber) {
if ( reFindNoCase('^(1Z)[0-9A-Z]{16}$|^(T)+[0-9A-Z]{10}$|^[0-9]{9}$|^[0-9]{26}$',arguments.trackingNumber,'true') ) {
return {
'success': true,
'data': 'UPS',
'msg': 'This is a UPS tracking number.'
};
} else {
return {
'success': false
};
}
}
/**
* Check if tracking number is FedEx
* @trackingNumber the tracking number you wish to find the shipper name of
*/
public function isFedEX(required string trackingNumber) {
if ( reFindNoCase('^[0-9]{15}$|^[0-9]{12}$',arguments.trackingNumber,'true') ) {
return {
'success': true,
'data': 'FedEx',
'msg': 'This is a FedEx tracking Number.'
};
} else {
return {
'success': false
};
}
}
}