diff --git a/manifest.konnector b/manifest.konnector index d84958bb96ffb2322832ed64b307415629d7ce56..5c8db4a4295980a10ce1f59de3d03ad2822a9a2d 100644 --- a/manifest.konnector +++ b/manifest.konnector @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "0.1.1", "name": "Enedis", "type": "konnector", "language": "node", diff --git a/package.json b/package.json index 80473656962935c132a0c11a18712aba417e9b8a..fc5a2652ab55f51b7fc81adde23509c1b221f703 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "enedis", - "version": "0.1.0", + "version": "0.1.1", "description": "", "repository": { "type": "git", diff --git a/src/index.js b/src/index.js index bafdd957b8c37a17d709df4e9fd8917078cb3dee..196494331134172e5bb44dd91f16709fd96dee65 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,7 @@ const startLoadDate = moment() .subtract(7, 'day') .format('YYYY-MM-DD') const endDate = moment().format('YYYY-MM-DD') -const baseUrl = 'https://gw.hml.api.enedis.fr' +const baseUrl = 'https://gw.prd.api.enedis.fr' /** * The start function is run by the BaseKonnector instance only when it got all the account @@ -43,9 +43,21 @@ async function start(fields, cozyParameters, doRetry = true) { const accountId = getAccountId() try { const { access_token } = fields - // const { oauth_callback_results } = fields - // const usage_point_id = oauth_callback_results.usage_point_id - const usage_point_id = 22516914714270 + let usage_point_id = '' + if ( + this._account && + this._account.oauth_callback_results && + this._account.oauth_callback_results.usage_points_id + ) { + const usage_points_id = this._account.oauth_callback_results.usage_points_id.split( + ',' + ) + usage_point_id = usage_points_id[0] + } else { + log('error', 'no usage_point_id found') + throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED + } + log('info', 'Fetching enedis daily data') const fetchedDailyData = await getDailyData(access_token, usage_point_id) log('info', 'Process enedis daily data')