Passed
Push — master ( 615aaf...b3b4bb )
by Ray
11:49
created

getEnginesByYearMakeModelTrimAndTransmission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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