How to use the cozy-client.fromEnv function in cozy-client

To help you get started, we’ve selected a few cozy-client 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 / targets / services / onOperationOrBillCreate.js View on Github external
const main = async () => {
  attachProcessEventHandlers()
  const client = CozyClient.fromEnv(process.env)
  Document.registerClient(client)
  const options = await getOptions(cozyClient)
  log('info', 'Options:')
  log('info', JSON.stringify(options))
  await onOperationOrBillCreate(client, options)
}
github cozy / cozy.github.io / en / cozy-banks / src / ducks / notifications / services.js View on Github external
export const sendNotifications = async (config, transactions) => {
  const enabledNotificationClasses = getEnabledNotificationClasses(config)
  const client = CozyClient.fromEnv(process.env)
  const accounts = await fetchTransactionAccounts(transactions)
  const groups = await fetchGroups(client)
  log(
    'info',
    `${transactions.length} new transactions on ${accounts.length} accounts.`
  )
  for (const Klass of enabledNotificationClasses) {
    await sendNotificationForClass(Klass, {
      client,
      lang,
      config,
      data: {
        accounts,
        groups,
        transactions
      }