Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
egl-api-connector
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
POCS
cozy
egl-api-connector
Commits
78b110d7
Commit
78b110d7
authored
5 years ago
by
i-vall
Browse files
Options
Downloads
Patches
Plain Diff
fix: correct use of COZY_PARAMETERS env. variable
parent
fcf89135
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
src/index.js
+13
-8
13 additions, 8 deletions
src/index.js
with
14 additions
and
8 deletions
.gitignore
+
1
−
0
View file @
78b110d7
...
@@ -32,3 +32,4 @@ desktop.ini
...
@@ -32,3 +32,4 @@ desktop.ini
# Default
# Default
# /!\ KEEP THIS SECTION THE LAST ONE
# /!\ KEEP THIS SECTION THE LAST ONE
!.gitkeep
!.gitkeep
params.md
This diff is collapsed.
Click to expand it.
src/index.js
+
13
−
8
View file @
78b110d7
...
@@ -11,23 +11,28 @@ const moment = require('moment')
...
@@ -11,23 +11,28 @@ const moment = require('moment')
//const moment = require('moment')
//const moment = require('moment')
//require('request-debug')(rp)
//require('request-debug')(rp)
const
baseUrl
=
process
.
env
.
COZY_PARAMETERS
.
eglBaseURL
const
apiAuthKey
=
process
.
env
.
COZY_PARAMETERS
.
eglAPIAuthKey
module
.
exports
=
new
BaseKonnector
(
start
)
module
.
exports
=
new
BaseKonnector
(
start
)
// The start function is run by the BaseKonnector instance only when it got all the account
// The start function is run by the BaseKonnector instance only when it got all the account
// information (fields). When you run this connector yourself in "standalone" mode or "dev" mode,
// information (fields). When you run this connector yourself in "standalone" mode or "dev" mode,
// the account information come from ./konnector-dev-config.json file
// the account information come from ./konnector-dev-config.json file
async
function
start
(
fields
)
{
async
function
start
(
fields
,
cozyParameters
)
{
try
{
try
{
// resetting data for demo only
// resetting data for demo only
// await resetData()
// await resetData()
const
baseUrl
=
cozyParameters
.
secret
.
eglBaseURL
const
apiAuthKey
=
cozyParameters
.
secret
.
eglAPIAuthKey
log
(
'
info
'
,
'
Authenticating ...
'
)
log
(
'
info
'
,
'
Authenticating ...
'
)
const
response
=
await
authenticate
(
fields
.
login
,
fields
.
password
)
const
response
=
await
authenticate
(
fields
.
login
,
fields
.
password
,
baseUrl
,
apiAuthKey
)
log
(
'
info
'
,
'
Successfully logged in
'
)
log
(
'
info
'
,
'
Successfully logged in
'
)
log
(
'
info
'
,
'
Getting data
'
)
log
(
'
info
'
,
'
Getting data
'
)
const
loadProfile
=
await
getData
(
response
)
const
loadProfile
=
await
getData
(
response
,
baseUrl
,
apiAuthKey
)
log
(
'
info
'
,
'
Saving data to Cozy
'
)
log
(
'
info
'
,
'
Saving data to Cozy
'
)
storeLoadProfile
(
loadProfile
)
storeLoadProfile
(
loadProfile
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -35,7 +40,7 @@ async function start(fields) {
...
@@ -35,7 +40,7 @@ async function start(fields) {
}
}
}
}
async
function
authenticate
(
login
,
password
)
{
async
function
authenticate
(
login
,
password
,
baseUrl
,
apiAuthKey
)
{
const
authRequest
=
{
const
authRequest
=
{
method
:
'
POST
'
,
method
:
'
POST
'
,
uri
:
baseUrl
+
'
/connect.aspx
'
,
uri
:
baseUrl
+
'
/connect.aspx
'
,
...
@@ -61,7 +66,7 @@ async function authenticate(login, password) {
...
@@ -61,7 +66,7 @@ async function authenticate(login, password) {
}
}
}
}
async
function
getData
(
response
)
{
async
function
getData
(
response
,
baseUrl
,
apiAuthKey
)
{
const
dataRequest
=
{
const
dataRequest
=
{
method
:
'
POST
'
,
method
:
'
POST
'
,
uri
:
baseUrl
+
'
/getAllAgregatsByAbonnement.aspx
'
,
uri
:
baseUrl
+
'
/getAllAgregatsByAbonnement.aspx
'
,
...
...
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