async function recursiveBatchCall(gladys, externalId, syncDelayBetweenCallsInMs, after = '2000-01-01') {
  const usagePointId = getUsagePointIdFromExternalId(externalId);
  logger.info(`Enedis: Syncing ${usagePointId} after ${after}`);
  const data = await gladys.gateway.enedisGetDailyConsumption({
    usage_point_id: usagePointId,
    after,
    take: ENEDIS_SYNC_BATCH_SIZE,
  });

  // Foreach value returned in the interval, we save it slowly in DB
  await Promise.each(data, async (value) => {
    gladys.event.emit(EVENTS.DEVICE.NEW_STATE, {
      device_feature_external_id: externalId,
      state: value.value,
      created_at: new Date(value.created_at),
    });
    await Promise.delay(syncDelayBetweenCallsInMs / 10);
  });
  await Promise.delay(syncDelayBetweenCallsInMs);

  // If there was still some data to get
  if (data.length === ENEDIS_SYNC_BATCH_SIZE) {
    const lastEntry = data[data.length - 1];
    return recursiveBatchCall(gladys, externalId, syncDelayBetweenCallsInMs, lastEntry.created_at);
  }
  if (data.length === 0) {
    return after;
  }
  return data[data.length - 1].created_at;
}
@description Get one batch of enedis data, then call the next one.
@param {object} gladys - Gladys object reference.
@param {string} externalId - Enedis usage point external id.
@param {number} syncDelayBetweenCallsInMs - Delay between calls in ms.
@param {string} after - Get data after this date.
@returns {Promise<string>} - Resolve with last date.
@example await recursiveBatchCall('usage-point');