getProductTags static method

Future<Map<String, ProductTag>> getProductTags({
  1. required String barcode,
  2. QueryType? queryType,
})

Returns all the ProductTags for this product

The key of the returned map is the tag key.

Implementation

static Future<Map<String, ProductTag>> getProductTags({
  required final String barcode,
  final QueryType? queryType,
}) async {
  final Map<String, String> parameters = <String, String>{};
  /* TODO
  if (owner != null) {
    parameters['owner'] = owner;
  }
   */
  final Response response = await HttpHelper().doGetRequest(
    UriHelper.getFolksonomyUri(
      path: 'product/$barcode',
      queryParameters: parameters,
      queryType: queryType,
    ),
    queryType: queryType,
  );
  _checkResponse(response);
  final Map<String, ProductTag> result = <String, ProductTag>{};
  if (response.body == 'null') {
    // not found
    return result;
  }
  final List<dynamic> json = jsonDecode(response.body) as List<dynamic>;
  for (var element in json) {
    final ProductTag productTag = ProductTag.fromJson(element);
    result[productTag.key] = productTag;
  }
  return result;
}