diff --git a/index.js b/index.js
index 384f8a2..fdc89a1 100644
--- a/index.js
+++ b/index.js
@@ -40,9 +40,7 @@ function logIn (fields) {
return rq(options)
.then(res => {
- //const isNoLocation = !res.headers.location
const isNot200 = res.statusCode !== 200
- //const isError = res.headers.location && res.headers.location.indexOf('error') !== -1
if (isNot200) {
log('info', 'Authentification error')
throw new Error('LOGIN_FAILED')
@@ -57,33 +55,30 @@ function logIn (fields) {
})
}
-// Parse the fetched page to extract bill data.
+// Parse the fetched DOM page to extract bill data.
function parsePage ($) {
const bills = []
-
$('.invoice-line').each(function () {
- //console.log($(this).html())
+ //one bill per line = a
with 'invoice-id' data-attr
let billId = $(this).data('invoice-id')
+
let amount = $(this).find('.amount').text()
amount = amount.replace('€','')
amount = amount.replace(',', '.').trim()
amount = parseFloat(amount)
+ //gets pdf download URL
let pdfUrl = $(this).find('a > i').data('url')
pdfUrl = baseUrl + pdfUrl
-
- //pdfUrl = `https://adsl.free.fr/${pdfUrl}`
+ //-YYYY format (Décembre - 2017)
let billDate = $(this).find('.invoiceDate').text().trim()
let monthAndYear = billDate.split('-')
let billYear = monthAndYear[0].trim()
let billMonth = monthAndYear[1].trim()
- //console.log(billMonth.toLowerCase())
+
billMonth = moment.months().indexOf(billMonth.toLowerCase()) + 1
billMonth = billMonth < 10 ? '0' + billMonth : billMonth
- //console.log(billMonth+"*"+billYear + "-----|" + billId + '->' + amount + "|||"+pdfUrl)
-
- //let month = "12"//pdfUrl.split('&')[2].split('=')[1]
let date = moment(billYear + billMonth, 'YYYYMM')
let bill = {
diff --git a/manifest.konnector b/manifest.konnector
index 61ef74f..15a6b23 100644
--- a/manifest.konnector
+++ b/manifest.konnector
@@ -2,8 +2,8 @@
"version": "1.0.0",
"name": "Enercoop Cozy konnector",
"type": "node",
- "slug": "konnectorslug",
- "description": "Collects your Enercoop's bills",
+ "slug": "enercoopslug",
+ "description": "Collects your Enercoop bills",
"source": "https://gitlab.allella.io/dje/cozy-konnector-enercoop",
"locales": {
"fr": {