Newer
Older

Bastien DUMONT
committed
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
const { log } = require('cozy-konnector-libs')
const { isLocal } = require('./env')
function getAccountId() {
log('info', `getAccountId`)
try {
return JSON.parse(process.env.COZY_FIELDS).account
} catch (err) {
throw new Error(`You must provide 'account' in COZY_FIELDS: ${err.message}`)
}
}
function getAccountRev() {
log('info', `getAccountRev`)
try {
return isLocal()
? 'fakeAccountRev'
: JSON.parse(process.env.COZY_FIELDS).account_rev
} catch (err) {
throw new Error(`You must provide 'account' in COZY_FIELDS: ${err.message}`)
}
}
/**
* Return account secrets.
* For local testing, change value with values from your konnector-dev-config.json
*/
function getAccountSecret() {
try {
return isLocal()
? {
baseUrl: 'https://test.fr',
sgeLogin: 'test@test.com',
contractId: '134567',
boBaseUrl: 'https://botest.grandlyon.com/',
boToken: 'tok31n',
apiAuthKey: 'authkeYeasqqd56dsdq',
}
: JSON.parse(process.env.COZY_PARAMETERS).secret
} catch (err) {
throw new Error(
`You must provide 'account-types' in COZY_PARAMETERS: ${err.message}`
)
}
}
module.exports = { getAccountId, getAccountRev, getAccountSecret }