-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvots.php
126 lines (100 loc) · 3.34 KB
/
vots.php
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
124
<?php
/**
* VOTS Service
* by Kyle Arrington ([email protected])
*
* A JSON wrapper for checking the status of a Jeep in production
*
* Last name/Last 8 of VIN are required
*
*/
class VOTSService {
public $lastname;
public $vin;
public static $decoded;
public static $raw;
private $codes = array(
"BB" => "review by fleet department",
"BD" => "special equipment processing",
"BE" => "edit error",
"BG" => "passed edit n/a for schedule",
"BGL" => "edit ok parts unavailable",
"BX" => "passed edit available for schedule",
"C" => "sub firm",
"D" => "firm schedule - dealer has allocation and all parts available",
"D1" => "gateline schedule - scheduled to be built",
"E" => "frame",
"F" => "paint",
"G" => "trim",
"I" => "built not ok'd",
"J" => "built ok'd",
"JB" => "shipped to body vendor",
"JE" => "emission check",
"JS" => "shipped to storage",
"KZ" => "released by plant , invoiced",
"KZL" => "released - not shipped",
"KZM" => "first rail departure",
"KZN" => "first rail arrival",
"KZO" => "delayed/recieved",
"KZOA" => "plant holds",
"KZOB" => "zone/distribution holds",
"KZOC" => "carrier delays",
"KZOD" => "carrier holds",
"KZOE" => "mis-shipped vehicle",
"KZOF" => "show/test vehicle",
"KZOG" => "damaged vehicle",
"KZOH" => "all other reasons",
"KZT" => "second rail departure",
"KZU" => "second rail arrival",
"KZX" => "delivered to dealer",
"ZA" => "canceled",
);
public function __construct($json = NULL)
{
self::$decoded = $json;
}
public function getJSON($lastname, $vin)
{
//set our variables
$this->lastname = $lastname;
$this->vin = substr(trim($vin), -8);
//replace a space with +, as Chrysler expects
$lastname = preg_replace("/ /","+",$this->lastname);
$vin = $this->vin;
// Get VOTS Servlet
$response = file_get_contents("https://www.jeep.com/vots/VOTSServlet?firstName=&lastName=$lastname&vin_last8=$vin&service=json");
// Save the raw response for debug
$raw = $response;
//trim the crap off the front and back, wrapped in votsservice()
$response = rtrim(ltrim($response, "votsservice("), ")");
self::$decoded = json_decode($response, TRUE);
return TRUE;
}
public function isValid()
{
if (self::$decoded['Status'] == "failure")
{
return FALSE;
}
else
{
return TRUE;
}
}
public function getStatusCode()
{
return self::$decoded['StatusDetails']['cStatus'];
}
public function getStatusDesc()
{
return self::$decoded['StatusDetails']['statusDesc'];
}
public function getStatusExplanation()
{
return ucwords($this->codes[trim(self::$decoded['StatusDetails']['cStatus'])]);
}
public function getError()
{
return self::$decoded['ERROR_DESC'];
}
}