getEvents static method

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

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 UriHelper uriHelper = uriHelperEventsProd,
}) 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.getUri(
      path: '/events',
      queryParameters: parameters,
    ),
    uriHelper: uriHelper,
  );
  _checkResponse(response);
  final List<EventsBase> result = <EventsBase>[];
  final List<dynamic> json =
      HttpHelper().jsonDecode(response.body) as List<dynamic>;
  for (var element in json) {
    result.add(EventsBase.fromJson(element));
  }
  return result;
}