forked from luzmo-official/luzmo-sdk-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
81 lines (74 loc) · 1.55 KB
/
example.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 Cumulio = require('./cumulio');
// Connect
var client = new Cumulio({
api_key: '< Your API key >',
api_token: '< Your API token >'
});
// Example 1: create a new dataset
var dataset;
client.create('securable', {
type: 'dataset',
name: {
nl: 'Burrito-statistieken',
en: 'Burrito statistics'
}
})
// Example 2: update a dataset
.then(function(result) {
dataset = result;
return client.update('securable', dataset.id, {description: {nl: 'Het aantal geconsumeerde burrito\'s per type'}});
})
// Example 3: create columns
.then(function(dataset) {
return client.create(
'column', {
type: 'hierarchy',
format: '',
informat: 'hierarchy',
order: 0,
name: {nl: 'Type burrito'}
},
[
{
role: 'Securable',
id: dataset.id
}
]
);
})
.then(function() {
return client.create(
'column', {
type: 'numeric',
format: ',.0f',
informat: 'numeric',
order: 1,
name: {nl: 'Burrito-gewicht'}
},
[
{
role: 'Securable',
id: dataset.id
}
]
);
})
// Example 4: push 2 data points to a dataset
.then(function() {
return client.create(
'data',
{
securable_id: dataset.id,
data: [
['sweet', 126],
['sour', 352]
]
});
})
// Error handling & closing connection
.catch(function(error) {
console.error('API error:', error);
})
.finally(function() {
client.close();
});