import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'

const debug = require('debug')('aidoop:robotics:increment-count-get')

async function IncrementCounterGet(step, { logger, domain, closures, state }) {
  var { connection } = step

  var connectionInstance = ConnectionManager.getConnectionInstanceByName(domain, connection)
  if (!connectionInstance) {
    throw Error(`connection is not found : ${connectionInstance}`)
  }

  logger.info(`incrementCount: (${connectionInstance.incrementCount})`)

  return {
    data: connectionInstance.incrementCount
  }
}

IncrementCounterGet.parameterSpec = []

IncrementCounterGet.help = 'robotics/task/increment-count-get'

TaskRegistry.registerTaskHandler('increment-count-get', IncrementCounterGet)
