How to use the cozy-doctypes.BankTransaction.fetchChanges function in cozy-doctypes

To help you get started, we’ve selected a few cozy-doctypes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy.github.io / en / cozy-banks / src / ducks / appSuggestions / services.js View on Github external
export const findAppSuggestions = async setting => {
  log('info', 'Fetch transactions changes, triggers and apps suggestions')
  const [transactionsToCheck, triggers, suggestions] = await Promise.all([
    BankTransaction.fetchChanges(get(setting, 'appSuggestions.lastSeq')),
    Trigger.fetchAll(),
    AppSuggestion.fetchAll()
  ])

  log('info', `Fetched ${transactionsToCheck.documents.length} transactions`)
  log('info', `Fetched ${triggers.length} triggers`)
  log('info', `Fetched ${suggestions.length} apps suggestions`)

  set(setting, 'appSuggestions.lastSeq', transactionsToCheck.newLastSeq)

  log('info', 'Get not installed brands')
  const installedSlugs = triggers.map(getKonnectorFromTrigger)
  const brands = getNotInstalledBrands(installedSlugs)

  log('info', `${brands.length} not installed brands`)