<commit_before>/*
// This konnector retrieves invoices from website http://fr.vente-privee.com
// creation : 11/06/2016
// creator : https://github.com/SomeAverageDev
*/
'use strict'

const saveOnlyLastBill = false

const request = require('request').defaults({
  jar: true,
  rejectUnauthorized: false,
  followAllRedirects: true,
  headers: {
    'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) ' +
                  'Gecko/20100101 Firefox/47.0'
  }
})

const moment = require('moment')
const cheerio = require('cheerio')
const baseKonnector = require('../lib/base_konnector')

const filterExisting = require('../lib/filter_existing')
const localization = require('../lib/localization_manager')
const saveDataAndFile = require('../lib/save_data_and_file')
const linkBankOperation = require('../lib/link_bank_operation')
const Bill = require('../models/bill')
const log = require('printit')({
  prefix: 'vente-privee',
  date: true
})

const fileOptions = {
  vendor: 'vente-privee',
  dateFormat: 'YYYYMMDD'
}

const baseUrl = 'https://secure.fr.vente-privee.com'

// Konnector
const connector = module.exports = baseKonnector.createNew({
  name: 'Vente-Privée',
  vendorLink: baseUrl,
  category: 'others',
  color: {
    hex: '#E8308A',
    css: '#E8308A'
  },
  fields: {
    login: {
      type: 'text'
    },
    password: {
      type: 'password'
    },
    folderPath: {
      type: 'folder',
      advanced: true
    }
  },
  dataType: [
    'bill'
  ],
  models: [Bill],
  fetchOperations: [
    getHiddenInputs,
    logIn,
    parsePage,
    customFilterExisting,
    customSaveDataAndFile,
    linkBankOperation({
      log,
      model: Bill,
      identifier: 'VENTE PRIVEE.COM',
      minDateDelta: 4,
      maxDateDelta: 20,
      amountDelta: 0.1
    }),
    buildNotifContent,
    logOut
  ]
})

// Procedure to get hidden inputs
function getHiddenInputs (requiredFields, bills, data, next) {
  const url = `${baseUrl}/authentication/login/` +
              'FR?ReturnUrl=%2fmemberaccount%2forder'
  const options = {<commit_msg>[fix] Add new operaiton label to vente-privée (#663)<commit_after>/*
// This konnector retrieves invoices from website http://fr.vente-privee.com
// creation : 11/06/2016
// creator : https://github.com/SomeAverageDev
*/
'use strict'

const saveOnlyLastBill = false

const request = require('request').defaults({
  jar: true,
  rejectUnauthorized: false,
  followAllRedirects: true,
  headers: {
    'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) ' +
                  'Gecko/20100101 Firefox/47.0'
  }
})

const moment = require('moment')
const cheerio = require('cheerio')
const baseKonnector = require('../lib/base_konnector')

const filterExisting = require('../lib/filter_existing')
const localization = require('../lib/localization_manager')
const saveDataAndFile = require('../lib/save_data_and_file')
const linkBankOperation = require('../lib/link_bank_operation')
const Bill = require('../models/bill')
const log = require('printit')({
  prefix: 'vente-privee',
  date: true
})

const fileOptions = {
  vendor: 'vente-privee',
  dateFormat: 'YYYYMMDD'
}

const baseUrl = 'https://secure.fr.vente-privee.com'

// Konnector
const connector = module.exports = baseKonnector.createNew({
  name: 'Vente-Privée',
  vendorLink: baseUrl,
  category: 'others',
  color: {
    hex: '#E8308A',
    css: '#E8308A'
  },
  fields: {
    login: {
      type: 'text'
    },
    password: {
      type: 'password'
    },
    folderPath: {
      type: 'folder',
      advanced: true
    }
  },
  dataType: [
    'bill'
  ],
  models: [Bill],
  fetchOperations: [
    getHiddenInputs,
    logIn,
    parsePage,
    customFilterExisting,
    customSaveDataAndFile,
    linkBankOperation({
      log,
      model: Bill,
      identifier: ['VENTE PRIVEE.COM', 'WWW.VENTE-PRIVEE.COM'],
      minDateDelta: 4,
      maxDateDelta: 20,
      amountDelta: 0.1
    }),
    buildNotifContent,
    logOut
  ]
})

// Procedure to get hidden inputs
function getHiddenInputs (requiredFields, bills, data, next) {
  const url = `${baseUrl}/authentication/login/` +
              'FR?ReturnUrl=%2fmemberaccount%2forder'
  const options = {
{'fraction_non_alphanumeric': 0.1499652858134691, 'fraction_numerical': 0.024299930571626938, 'mean_word_length': 3.2331047992164543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6794691', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1494, 'n_words': 306}