scheduleEventRequest method

Future<void> scheduleEventRequest(
  1. EventRequest eventRequest
)

Implementation

Future<void> scheduleEventRequest(EventRequest eventRequest) async {
  Debug.print("Scheduler: Event Request scheduled");
  batchedEventRequests.add(eventRequest);
  final pendingEvents = await requestCacher.retrieveRequests();
  if (pendingEvents.isNotEmpty) {
    batchedEventRequests.addAll(pendingEvents);
  }

  List<EventRequest> filteredRequests =
      removeDuplicates(batchedEventRequests);
  Debug.print(
    "Scheduler: RemoveDuplicates actual: ${batchedEventRequests.length} filtered: ${filteredRequests.length}",
  );
  batchedEventRequests = filteredRequests;

  if (batchedEventRequests.length >= _maxBatchSize) {
    await _sendBatchedApiCallsWithRetry();
  } else {
    _startTimer();
  }
}