batch method

Future<void> batch(
  1. List<DataPoint> batch
)

Batch upload a list of DataPoints.

Returns when successful. Throws a CarpServiceException if not.

Implementation

Future<void> batch(List<DataPoint> batch) async {
  if (batch.isEmpty) return;

  await File('${await fileCachePath}/batch-${_counter++}.json')
      .create(recursive: true)
      .then((file) => file.writeAsString(toJsonString(batch), flush: true))
      .then((file) => upload(file));
}