queryUsers method

Future<QueryUsersResponse> queryUsers (
  1. Map<String, dynamic> filter,
  2. List<SortOption> sort,
  3. Map<String, dynamic> options
)

Requests users with a given query.

Implementation

Future<QueryUsersResponse> queryUsers(
  Map<String, dynamic> filter,
  List<SortOption> sort,
  Map<String, dynamic> options,
) async {
  final defaultOptions = {
    'presence': _hasConnectionId,
  };

  final payload = <String, dynamic>{
    'filter_conditions': filter ?? {},
    'sort': sort,
  };

  payload.addAll(defaultOptions);

  if (options != null) {
    payload.addAll(options);
  }

  final rawRes = await get(
    '/users',
    queryParameters: {
      'payload': jsonEncode(payload),
    },
  );

  final response = decode<QueryUsersResponse>(
    rawRes.data,
    QueryUsersResponse.fromJson,
  );

  state?._updateUsers(response.users);

  return response;
}