|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Codebyray\LaravelVehapi; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Http; |
|
6
|
|
|
|
|
7
|
|
|
class LaravelVehapi |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var string |
|
11
|
|
|
*/ |
|
12
|
|
|
private $vehApiToken; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
private $vehApiVersion; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var boolean |
|
21
|
|
|
*/ |
|
22
|
|
|
private $vehCheckSslCert; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Create a new controller instance. |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->vehApiToken = config('laravel-vehapi.veh_api_token', null); |
|
30
|
|
|
$this->vehApiVersion = config('laravel-vehapi.veh_api_version', null); |
|
31
|
|
|
$this->vehCheckSslCert = config('laravel-vehapi.veh_check_ssl_cert', true); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Return all years available. |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $sort |
|
38
|
|
|
* |
|
39
|
|
|
* @return mixed |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getAllYears($sort = 'asc') |
|
42
|
|
|
{ |
|
43
|
|
|
return json_decode(Http::withOptions([ |
|
44
|
|
|
'verify' => $this->vehCheckSslCert |
|
45
|
|
|
]) |
|
46
|
|
|
->withToken($this->vehApiToken) |
|
47
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/years/'.$sort), true); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Return the range of years as supplied. |
|
52
|
|
|
* |
|
53
|
|
|
* @param int $minYear |
|
54
|
|
|
* @param int $maxYear |
|
55
|
|
|
* @param string $sort |
|
56
|
|
|
* |
|
57
|
|
|
* @return mixed |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getYearsRange(int $minYear, int $maxYear, $sort = 'asc') |
|
60
|
|
|
{ |
|
61
|
|
|
return json_decode(Http::withOptions([ |
|
62
|
|
|
'verify' => $this->vehCheckSslCert |
|
63
|
|
|
]) |
|
64
|
|
|
->withToken($this->vehApiToken) |
|
65
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/range/years/'.$minYear.'/'.$maxYear.'/'.$sort), true); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Return all makes available. |
|
70
|
|
|
* |
|
71
|
|
|
* @param string $sort |
|
72
|
|
|
* |
|
73
|
|
|
* @return mixed |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getAllMakes($sort = 'asc') |
|
76
|
|
|
{ |
|
77
|
|
|
return json_decode(Http::withOptions([ |
|
78
|
|
|
'verify' => $this->vehCheckSslCert |
|
79
|
|
|
]) |
|
80
|
|
|
->withToken($this->vehApiToken) |
|
81
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/all/car/makes/'.$sort), true); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Return the makes available for the year supplied. |
|
86
|
|
|
* |
|
87
|
|
|
* @param int $year |
|
88
|
|
|
* @param string $sort |
|
89
|
|
|
* |
|
90
|
|
|
* @return mixed |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getMakesByYear(int $year, $sort = 'asc') |
|
93
|
|
|
{ |
|
94
|
|
|
return json_decode(Http::withOptions([ |
|
95
|
|
|
'verify' => $this->vehCheckSslCert |
|
96
|
|
|
]) |
|
97
|
|
|
->withToken($this->vehApiToken) |
|
98
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/makes/'.$year.'/'.$sort), true); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Return the range of years as supplied. |
|
103
|
|
|
* |
|
104
|
|
|
* @param int $minYear |
|
105
|
|
|
* @param int $maxYear |
|
106
|
|
|
* @param string $sort |
|
107
|
|
|
* |
|
108
|
|
|
* @return mixed |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getMakesByYearsRange(int $minYear, int $maxYear, $sort = 'asc') |
|
111
|
|
|
{ |
|
112
|
|
|
return json_decode(Http::withOptions([ |
|
113
|
|
|
'verify' => $this->vehCheckSslCert |
|
114
|
|
|
]) |
|
115
|
|
|
->withToken($this->vehApiToken) |
|
116
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/makes/in-range/'.$minYear.'/'.$maxYear.'/'.$sort), true); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Return the models available for the make supplied. |
|
121
|
|
|
* |
|
122
|
|
|
* @param string $make |
|
123
|
|
|
* @param string $sort |
|
124
|
|
|
* |
|
125
|
|
|
* @return mixed |
|
126
|
|
|
*/ |
|
127
|
|
|
public function getAllModelsByMake(string $make, $sort = 'asc') |
|
128
|
|
|
{ |
|
129
|
|
|
return json_decode(Http::withOptions([ |
|
130
|
|
|
'verify' => $this->vehCheckSslCert |
|
131
|
|
|
]) |
|
132
|
|
|
->withToken($this->vehApiToken) |
|
133
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/all/car/models/'.$make.'/'.$sort), true); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Return the models available for the year & make supplied. |
|
138
|
|
|
* |
|
139
|
|
|
* @param int $year |
|
140
|
|
|
* @param string $make |
|
141
|
|
|
* @param string $sort |
|
142
|
|
|
* |
|
143
|
|
|
* @return mixed |
|
144
|
|
|
*/ |
|
145
|
|
|
public function getModelsByYearAndMake(int $year, string $make, $sort = 'asc') |
|
146
|
|
|
{ |
|
147
|
|
|
return json_decode(Http::withOptions([ |
|
148
|
|
|
'verify' => $this->vehCheckSslCert |
|
149
|
|
|
]) |
|
150
|
|
|
->withToken($this->vehApiToken) |
|
151
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/models/'.$year.'/'.$make.'/'.$sort), true); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Return the trims available for the year, make & model supplied. |
|
156
|
|
|
* |
|
157
|
|
|
* @param int $year |
|
158
|
|
|
* @param string $make |
|
159
|
|
|
* @param string $model |
|
160
|
|
|
* |
|
161
|
|
|
* @return mixed |
|
162
|
|
|
*/ |
|
163
|
|
|
public function getTrimsByYearMakeAndModel(int $year, string $make, string $model) |
|
164
|
|
|
{ |
|
165
|
|
|
return json_decode(Http::withOptions([ |
|
166
|
|
|
'verify' => $this->vehCheckSslCert |
|
167
|
|
|
]) |
|
168
|
|
|
->withToken($this->vehApiToken) |
|
169
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/trims/'.$year.'/'.$make.'/'.$model), true); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Return the transmissions available for the year, make,model & trim supplied. |
|
174
|
|
|
* |
|
175
|
|
|
* @param int $year |
|
176
|
|
|
* @param string $make |
|
177
|
|
|
* @param string $model |
|
178
|
|
|
* @param string $trim |
|
179
|
|
|
* |
|
180
|
|
|
* @return mixed |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getTransmissionsByYearMakeModelAndTrim(int $year, string $make, string $model, string $trim) |
|
183
|
|
|
{ |
|
184
|
|
|
return json_decode(Http::withOptions([ |
|
185
|
|
|
'verify' => $this->vehCheckSslCert |
|
186
|
|
|
]) |
|
187
|
|
|
->withToken($this->vehApiToken) |
|
188
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/transmissions/'.$year.'/'.$make.'/'.$model.'/'.$trim), true); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Return engines available for the year, make, model & transmission supplied. |
|
193
|
|
|
* |
|
194
|
|
|
* @param int $year |
|
195
|
|
|
* @param string $make |
|
196
|
|
|
* @param string $model |
|
197
|
|
|
* @param string $trim |
|
198
|
|
|
* @param string $transmission |
|
199
|
|
|
* |
|
200
|
|
|
* @return mixed |
|
201
|
|
|
*/ |
|
202
|
|
|
public function getEnginesByYearMakeModelTrimAndTransmission(int $year, string $make, string $model, string $trim, string $transmission) |
|
203
|
|
|
{ |
|
204
|
|
|
return json_decode(Http::withOptions([ |
|
205
|
|
|
'verify' => $this->vehCheckSslCert |
|
206
|
|
|
]) |
|
207
|
|
|
->withToken($this->vehApiToken) |
|
208
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/engines/'.$year.'/'.$make.'/'.$model.'/'.$trim.'/'.$transmission), true); |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Return options available for the year, make, model, transmission & engine supplied. |
|
213
|
|
|
* |
|
214
|
|
|
* @param int $year |
|
215
|
|
|
* @param string $make |
|
216
|
|
|
* @param string $model |
|
217
|
|
|
* @param string $trim |
|
218
|
|
|
* @param string $transmission |
|
219
|
|
|
* @param string $engine |
|
220
|
|
|
* |
|
221
|
|
|
* @return mixed |
|
222
|
|
|
*/ |
|
223
|
|
|
public function getOptionsByYearMakeModelTrimTransmissionAndEngine(int $year, string $make, string $model, string $trim, string $transmission, string $engine) |
|
224
|
|
|
{ |
|
225
|
|
|
return json_decode(Http::withOptions([ |
|
226
|
|
|
'verify' => $this->vehCheckSslCert |
|
227
|
|
|
]) |
|
228
|
|
|
->withToken($this->vehApiToken) |
|
229
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/options/'.$year.'/'.$make.'/'.$model.'/'.$trim.'/'.$transmission.'/'.$engine), true); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* Return wheels available for the year, make, model, transmission & engine supplied. |
|
234
|
|
|
* |
|
235
|
|
|
* @param int $year |
|
236
|
|
|
* @param string $make |
|
237
|
|
|
* @param string $model |
|
238
|
|
|
* @param string $trim |
|
239
|
|
|
* @param string $transmission |
|
240
|
|
|
* @param string $engine |
|
241
|
|
|
* |
|
242
|
|
|
* @return mixed |
|
243
|
|
|
*/ |
|
244
|
|
|
public function getWheelsByYearMakeModelTrimTransmissionAndEngine(int $year, string $make, string $model, string $trim, string $transmission, string $engine) |
|
245
|
|
|
{ |
|
246
|
|
|
return json_decode(Http::withOptions([ |
|
247
|
|
|
'verify' => $this->vehCheckSslCert |
|
248
|
|
|
]) |
|
249
|
|
|
->withToken($this->vehApiToken) |
|
250
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/wheels/'.$year.'/'.$make.'/'.$model.'/'.$trim.'/'.$transmission.'/'.$engine), true); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Return the logo for the make supplied. |
|
255
|
|
|
* |
|
256
|
|
|
* @param string $make |
|
257
|
|
|
* |
|
258
|
|
|
* @return mixed |
|
259
|
|
|
*/ |
|
260
|
|
|
public function getMakeLogo(string $make) |
|
261
|
|
|
{ |
|
262
|
|
|
return json_decode(Http::withOptions([ |
|
263
|
|
|
'verify' => $this->vehCheckSslCert |
|
264
|
|
|
]) |
|
265
|
|
|
->withToken($this->vehApiToken) |
|
266
|
|
|
->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-logos/img/'.$make), true); |
|
267
|
|
|
} |
|
268
|
|
|
} |
|
269
|
|
|
|