Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
enedis_sge_konnector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
enedis_sge_konnector
Commits
7a9ecb67
Commit
7a9ecb67
authored
2 years ago
by
Hugo SUBTIL
Browse files
Options
Downloads
Patches
Plain Diff
fix: env variable + add city field
parent
66fd49c0
No related branches found
No related tags found
1 merge request
!12
Feat/donnes tech debut contrat
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
manifest.konnector
+3
-0
3 additions, 0 deletions
manifest.konnector
src/helpers/env.js
+3
-1
3 additions, 1 deletion
src/helpers/env.js
src/helpers/getAccountId.js
+12
-0
12 additions, 0 deletions
src/helpers/getAccountId.js
src/index.js
+4
-5
4 additions, 5 deletions
src/index.js
with
22 additions
and
6 deletions
manifest.konnector
+
3
−
0
View file @
7a9ecb67
...
...
@@ -23,6 +23,9 @@
"postalCode": {
"type": "string"
},
"city": {
"type": "string"
},
"pointId": {
"type": "number"
}
...
...
This diff is collapsed.
Click to expand it.
src/helpers/env.js
+
3
−
1
View file @
7a9ecb67
function
iSLocal
()
{
return
process
.
env
.
NODE_ENV
===
'
development
'
||
process
.
env
.
NODE_ENV
return
(
process
.
env
.
NODE_ENV
===
'
development
'
||
process
.
env
.
NODE_ENV
===
'
local
'
)
}
module
.
exports
=
{
iSLocal
}
This diff is collapsed.
Click to expand it.
src/helpers/getAccountId.js
0 → 100644
+
12
−
0
View file @
7a9ecb67
function
getAccountId
()
{
try
{
return
process
.
env
.
NODE_ENV
===
'
development
'
||
process
.
env
.
NODE_ENV
===
'
test
'
?
'
fakeAccountId
'
:
JSON
.
parse
(
process
.
env
.
COZY_FIELDS
).
account
}
catch
(
err
)
{
throw
new
Error
(
`You must provide 'account' in COZY_FIELDS:
${
err
.
message
}
`
)
}
}
module
.
exports
=
{
getAccountId
}
This diff is collapsed.
Click to expand it.
src/index.js
+
4
−
5
View file @
7a9ecb67
...
...
@@ -33,7 +33,7 @@ const { verifyContract } = require('./core/contractVerification')
const
{
terminateContract
}
=
require
(
'
./core/contractTermination
'
)
const
{
getContractStartDate
}
=
require
(
'
./core/contractStartDate
'
)
const
{
getAccount
,
saveAccountData
}
=
require
(
'
./requests/cozy
'
)
const
{
iSLocal
}
=
require
(
'
./helpers/
env
'
)
const
{
getAccountId
}
=
require
(
'
./helpers/
getAccountId
'
)
moment
.
locale
(
'
fr
'
)
// set the language
moment
.
tz
.
setDefault
(
'
Europe/Paris
'
)
// set the timezone
...
...
@@ -48,7 +48,6 @@ let startDailyDateString = startDailyDate.format('YYYY-MM-DD')
const
startLoadDate
=
moment
().
subtract
(
7
,
'
day
'
)
const
endDate
=
moment
()
const
endDateString
=
endDate
.
format
(
'
YYYY-MM-DD
'
)
const
ACCOUNT_ID
=
iSLocal
()
?
'
default_account_id
'
:
'
enedis-sge-grandlyon
'
module
.
exports
=
new
BaseKonnector
(
start
)
...
...
@@ -62,14 +61,14 @@ module.exports = new BaseKonnector(start)
* @param {{secret: fields}} cozyParameters
*/
async
function
start
(
fields
,
cozyParameters
)
{
log
(
'
info
'
,
'
Gathering data ...
'
)
log
(
'
info
'
,
'
Konnector configuration ...
'
)
const
ACCOUNT_ID
=
await
getAccountId
()
const
pointId
=
fields
.
pointId
let
baseUrl
=
fields
.
wso2BaseUrl
let
apiAuthKey
=
fields
.
apiToken
let
contractId
=
fields
.
contractId
//TODO switch variable to english
let
sgeLogin
=
fields
.
sgeLogin
log
(
'
info
'
,
'
Authenticating ...
'
)
//TODO: Verify if condition is working in local and on build version
if
(
cozyParameters
&&
Object
.
keys
(
cozyParameters
).
length
!==
0
)
{
log
(
'
debug
'
,
'
Found COZY_PARAMETERS
'
)
...
...
@@ -95,7 +94,7 @@ async function start(fields, cozyParameters) {
*/
log
(
'
info
'
,
'
User Logging...
'
)
if
(
await
isFirstStart
(
await
getAccount
(
'
default_account_id
'
)))
{
if
(
await
isFirstStart
(
await
getAccount
(
ACCOUNT_ID
)))
{
const
user
=
await
verifyUserIdentity
(
fields
,
baseUrl
,
apiAuthKey
,
sgeLogin
)
let
consent
=
await
createBoConsent
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment