-
Notifications
You must be signed in to change notification settings - Fork 22
/
sample.php
42 lines (35 loc) · 1.21 KB
/
sample.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
<?php
require __DIR__ . '/vendor/autoload.php';
$sampleUserId = "b41B4DC05";
$sampleHOSId = "aDVrUIaQ1ZUWmoTIDd--AJb";
$defaultErrorCallback = function ($error) {
var_dump($error);
};
$api = new Geotab\API(MYGEOTAB_USERNAME, MYGEOTAB_PASSWORD, MYGEOTAB_DATABASE, "my.geotab.com");
$api->authenticate();
echo "Get User\n";
$api->get("User", ["search" => ["id" => $sampleUserId], "resultsLimit" => 1], function ($results) use (&$api, &$defaultErrorCallback) {
$user = $results[0];
$user["firstName"] .= "1234";
echo "Set User\n";
$api->set("User", $user, function ($results) {
var_dump($results);
}, $defaultErrorCallback);
}, $defaultErrorCallback);
echo "Add DutyStatusLog\n";
$api->add("DutyStatusLog", ["entity" => [
"id" => $sampleHOSId,
"dateTime" => "2015-12-05T05:24:35.095Z",
"device" => ["id" => "b3"],
"driver" => ["id" => $sampleUserId],
"status" => "ON"
]], function ($results) {
var_dump($results);
}, $defaultErrorCallback);
echo "MultiCall\n";
$api->multiCall([
["Get", ["typeName" => "Device", "resultsLimit" => 1]],
["Get", ["typeName" => "Device", "resultsLimit" => 1]]
], function ($results) {
var_dump($results);
}, $defaultErrorCallback);