getEventsCount static method

Future<Map<String, int>> getEventsCount({
  1. String? userId,
  2. String? deviceId,
  3. QueryType? queryType,
})

Returns all the events counts, with optional filters.

Implementation

static Future<Map<String, int>> getEventsCount({
  final String? userId,
  final String? deviceId,
  final QueryType? queryType,
}) async {
  final Map<String, String> parameters = <String, String>{};
  if (userId != null) {
    parameters['user_id'] = userId;
  }
  if (deviceId != null) {
    parameters['device_id'] = deviceId;
  }
  final Response response = await HttpHelper().doGetRequest(
    UriHelper.getEventsUri(
      path: '/events/count',
      queryParameters: parameters,
      queryType: queryType,
    ),
    queryType: queryType,
  );
  _checkResponse(response);
  final Map<String, int> result = <String, int>{};
  final Map<String, dynamic> json =
      jsonDecode(response.body) as Map<String, dynamic>;
  for (final String key in json.keys) {
    result[key] = json[key] as int;
  }
  return result;
}