-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.php
114 lines (82 loc) · 2.94 KB
/
test.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
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use CarApiSdk\CarApi;
use CarApiSdk\JsonSearch;
use CarApiSdk\JsonSearchItem;
use CarApiSdk\Powersports;
/*
* This file runs a live test using the SDK. You must create a .env file with a TOKEN, SECRET and HOST.
*
* This can be run via: php test.php
*/
$env = (new josegonzalez\Dotenv\Loader('./.env'))
->parse()
->toEnv()
->toArray();
if (!isset($env['TOKEN'], $env['SECRET'], $env['HOST'])) {
throw new LogicException('An .env file is required and must contain a TOKEN, SECRET and HOST.');
}
function println(string $string) {
echo "\n\n$string\n\n";
}
$sdk = CarApi::build([
'token' => $env['TOKEN'],
'secret' => $env['SECRET'],
'host' => $env['HOST'],
'httpVersion' => '1.1',
'encoding' => ['gzip'],
]);
println('JWT:' . $sdk->authenticate());
println('Years:');
print_r($sdk->years(['query' => ['make' => 'Tesla']]));
println('Makes:');
print_r($sdk->makes(['query' => ['limit' => 1, 'page' => 0]]));
println('Models:');
print_r($sdk->models(['query' => ['make' => 'Tesla', 'limit' => 1]]));
println('Trims:');
$json = new JsonSearch();
$json->addItem(new JsonSearchItem('make', 'like', 'Tesla'));
print_r($sdk->trims(['query' => ['json' => $json, 'limit' => 1]]));
println('Trims:');
print_r($sdk->trimItem(1));
println('Bodies:');
print_r($sdk->bodies(['query' => ['make' => 'Tesla', 'limit' => 1]]));
println('Engines:');
print_r($sdk->engines(['query' => ['make' => 'Tesla', 'limit' => 1]]));
println('Mileages:');
print_r($sdk->mileages(['query' => ['make' => 'Tesla', 'limit' => 1]]));
println('VIN:');
print_r($sdk->vin('1GTG6CEN0L1139305'));
println('Interior Colors:');
print_r($sdk->interiorColors(['query' => ['make' => 'Tesla', 'limit' => 1]]));
println('Exterior Colors:');
print_r($sdk->exteriorColors(['query' => ['make' => 'Tesla', 'limit' => 1]]));
println('Vehicle Attributes:');
print_r($sdk->vehicleAttributes('bodies.type'));
println('Account Requests:');
print_r($sdk->accountRequests());
/*println('Account Requests Today:');
print_r($sdk->accountRequestsToday());*/
println('License Plate:');
print_r($sdk->licensePlate('US', 'LNP8460#TEST', 'NY'));
println('OBD Codes:');
print_r($sdk->obdCodes(['query' => ['limit' => 1]]));
println('Single OBD Code:');
print_r($sdk->obdCodeItem('B1200'));
println('Done with Vehicles!');
$sdk = Powersports::build([
'token' => $env['TOKEN'],
'secret' => $env['SECRET'],
'host' => 'http://localhost:8080',
'httpVersion' => '1.1',
'encoding' => ['gzip'],
]);
println('JWT:' . $sdk->authenticate());
println('Years:');
print_r($sdk->years(['query' => ['make' => 'Honda', 'type' => 'street_motorcycle']]));
println('Makes:');
print_r($sdk->makes(['query' => ['limit' => 1, 'page' => 0, 'type' => 'street_motorcycle']]));
println('Models:');
print_r($sdk->models(['query' => ['make' => 'Honda', 'limit' => 1, 'type' => 'street_motorcycle']]));
println('Done with Powersports!');