Newer
Older
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const axios = require('axios')
const config = require('./config')
const headers = {
Accept: 'application/json',
Authorization: config.authorization,
Cookie: config.cookie,
'content-type': 'application/json',
}
const dataEnedisAccount = JSON.stringify({
account_type: 'enedisgrandlyon',
name: '',
oauth: {
access_token: '',
expires_at: '2020-10-09T08:00:00.285910671+02:00',
refresh_token: '',
token_type: 'Bearer',
},
oauth_callback_results: {
issued_at: '1592232569642',
refresh_token_issued_at: '1592232569642',
scope:
'/v4/metering_data/production_load_curve.GET /v3/customers/usage_points/addresses.GET /v4/metering_data/consumption_load_curve.GET /v3/customers/usage_points/contracts.GET /v4/metering_data/daily_production.GET /v4/metering_data/daily_consumption.GET /v4/metering_data/daily_consumption_max_power.GET /v3/customers/identity.GET',
usage_points_id: '',
},
})
const dataGrdfAccount = JSON.stringify({
account_type: 'grdfgrandlyon',
auth: {
credentials_encrypted:
'bmFjbMKrNCS+4Liakxdu+xNu9I3sSyvda8iAp0o3U3OAymbIeoLhLtxPdsa+3mu/8yTnDudBcJo=',
login: 'test',
},
id: '89e68b8450cee09fe2f077610901094d',
identifier: 'login',
state: null,
})
const dataEglAccount = JSON.stringify({
account_type: 'eglgrandlyon',
auth: {
credentials_encrypted:
'bmFjbHI5OoL+VNCT6JDFYea1dNiBGGNJM1zY0M4uWcjhALJcQT9uk9p9WPD7+1OryCAoYf9eaSE=',
login: 'test',
},
id: '90e68b8450cee09fe2f077610901094d',
identifier: 'login',
state: null,
})
const dataEnedisTrigger = JSON.stringify({
data: {
attributes: {
_id: '3ed832cec67e6e0b2c6382edd30df11c',
domain: 'cozy.tools:8080',
prefix: 'cozy35ba44d2d1749e6f21646edce51e7190',
type: '@cron',
worker: 'konnector',
arguments: '0 47 8 * * *',
debounce: '',
options: null,
message: {
account: '88e68b8450cee09fe2f077610901094d',
konnector: 'enedisgrandlyon',
},
cozyMetadata: {
doctypeVersion: '1',
metadataVersion: 1,
createdAt: '2020-10-09T08:00:00.6092798Z',
createdByApp: 'ecolyo',
updatedAt: '2020-10-09T08:00:00.6092798Z',
},
},
},
})
const dataGrdfTrigger = JSON.stringify({
data: {
attributes: {
_id: '4ed832cec67e6e0b2c6382edd30df11c',
domain: 'cozy.tools:8080',
prefix: 'cozy35ba44d2d1749e6f21646edce51e7190',
type: '@cron',
worker: 'konnector',
arguments: '0 47 8 * * *',
debounce: '',
options: null,
message: {
account: '89e68b8450cee09fe2f077610901094d',
konnector: 'grdfgrandlyon',
},
cozyMetadata: {
doctypeVersion: '1',
metadataVersion: 1,
createdAt: '2020-10-09T08:00:00.6092798Z',
createdByApp: 'ecolyo',
updatedAt: '2020-10-09T08:00:00.6092798Z',
},
},
},
})
const dataEglTrigger = JSON.stringify({
data: {
attributes: {
_id: '5ed832cec67e6e0b2c6382edd30df11c',
domain: 'cozy.tools:8080',
prefix: 'cozy35ba44d2d1749e6f21646edce51e7190',
type: '@cron',
worker: 'konnector',
arguments: '0 47 8 * * *',
debounce: '',
options: null,
message: {
account: '90e68b8450cee09fe2f077610901094d',
konnector: 'eglgrandlyon',
},
cozyMetadata: {
doctypeVersion: '1',
metadataVersion: 1,
createdAt: '2020-10-09T08:00:00.6092798Z',
createdByApp: 'ecolyo',
updatedAt: '2020-10-09T08:00:00.6092798Z',
},
},
},
})
async function launch() {
// Enedis
await axios({
method: 'put',
url: 'http://cozy.tools:8080/data/io.cozy.accounts/88e68b8450cee09fe2f077610901094d',
headers: headers,
data: dataEnedisAccount,
})
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
await axios({
method: 'post',
url: 'http://cozy.tools:8080/jobs/triggers',
headers: headers,
data: dataEnedisTrigger,
})
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
// GRDF
await axios({
method: 'put',
url: 'http://cozy.tools:8080/data/io.cozy.accounts/89e68b8450cee09fe2f077610901094d',
headers: headers,
data: dataGrdfAccount,
})
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
await axios({
method: 'post',
url: 'http://cozy.tools:8080/jobs/triggers',
headers: headers,
data: dataGrdfTrigger,
})
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
// EGL
await axios({
method: 'put',
url: 'http://cozy.tools:8080/data/io.cozy.accounts/90e68b8450cee09fe2f077610901094d',
headers: headers,
data: dataEglAccount,
})
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
await axios({
method: 'post',
url: 'http://cozy.tools:8080/jobs/triggers',
headers: headers,
data: dataEglTrigger,
})
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
}
launch()