-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.js
81 lines (69 loc) · 1.63 KB
/
examples.js
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
var sm = require('./spritmonitor.js')
function errorHandler(_err)
{
console.log("ERROR: " + JSON.stringify(_err) + _err);
}
sm.getCars((_cars) =>
{
console.log("Cars:\n" + JSON.stringify(_cars, null, 4));
for(var i in _cars)
{
var car = _cars[i];
console.log("Car ID: " + car.id + "\n" + JSON.stringify(car,null,4));
sm.getFuelings(car.id, 5, (_fuelings) =>
{
console.log("Last five fuelings for car " + car.make + " " + car.model + ":\n" +
JSON.stringify(_fuelings, null, 2));
}, () => {});
}
},
errorHandler);
sm.getUnits((_units) =>
{
console.log("Units:\n" + JSON.stringify(_units, null, 4));
},
errorHandler);
sm.getCompanies((_companies) =>
{
console.log("Companies:\n" + JSON.stringify(_companies, null, 4));
},
errorHandler);
sm.getFuelSorts((_fuelsorts) =>
{
console.log("Fuel Sorts:\n" + JSON.stringify(_fuelsorts, null, 4));
},
errorHandler);
sm.getCostTypes((_fuelsorts) =>
{
console.log("Cost Types:\n" + JSON.stringify(_fuelsorts, null, 4));
},
errorHandler);
sm.getCurrencies((_currencies) =>
{
console.log("Currencies:\n" + JSON.stringify(_currencies, null, 4));
},
errorHandler);
sm.getQuantityUnits((_res) =>
{
console.log("Quantity Units:\n" + JSON.stringify(_res, null, 4));
},
errorHandler);
sm.addFueling(123456,
{
"note": "Automatic entry from NodeJS",
"fuelsort": "Diesel",
"currency": "EUR",
"position": {
"lat": "55.55555",
"lon": "6.66666"
},
"country": "D",
"location": "Hamburg",
"odometer": "87654",
"quantity": "12.34",
"price": "23.45",
"date": new Date()
}, (_success) =>
{
console.log("Successfully added fueling");
}, errorHandler);