getEvents static method

Future<List<EventsBase>> getEvents({
  1. String? userId,
  2. String? deviceId,
  3. int? skip,
  4. int? limit,
  5. QueryType? queryType,
})

Returns all the EventsBase, with optional filters and paging.

Implementation

static Future<List<EventsBase>> getEvents({
  final String? userId,
  final String? deviceId,
  final int? skip,
  final int? limit,
  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;
  }
  if (skip != null) {
    parameters['skip'] = skip.toString();
  }
  if (limit != null) {
    parameters['limit'] = limit.toString();
  }
  final Response response = await HttpHelper().doGetRequest(
    UriHelper.getEventsUri(
      path: '/events',
      queryParameters: parameters,
      queryType: queryType,
    ),
    queryType: queryType,
  );
  _checkResponse(response);
  final List<EventsBase> result = <EventsBase>[];
  final List<dynamic> json = jsonDecode(response.body) as List<dynamic>;
  for (var element in json) {
    result.add(EventsBase.fromJson(element));
  }
  return result;
}