getValues static method

Future<Map<String, ValueCount>> getValues({
  1. required String key,
  2. String? owner,
  3. String? query,
  4. int? limit,
  5. UriHelper uriHelper = uriHelperFolksonomyProd,
})

Returns the list of values related to tag keys with statistics.

Implementation

static Future<Map<String, ValueCount>> getValues({
  required final String key,
  final String? owner,
  final String? query,
  final int? limit,
  final UriHelper uriHelper = uriHelperFolksonomyProd,
}) async {
  final Map<String, String> parameters = <String, String>{
    if (owner != null) 'owner': owner,
    if (query != null) 'q': query,
    if (limit != null) 'limit': limit.toString(),
  };
  final Response response = await HttpHelper().doGetRequest(
    uriHelper.getUri(
      path: 'values/$key',
      queryParameters: parameters,
    ),
    uriHelper: uriHelper,
  );
  _checkResponse(response);
  final Map<String, ValueCount> result = <String, ValueCount>{};
  final List<dynamic> json =
      HttpHelper().jsonDecode(response.body) as List<dynamic>;
  for (var element in json) {
    final ValueCount item = ValueCount.fromJson(element);
    result[item.value] = item;
  }
  return result;
}