getProductTagVersions static method

Future<List<ProductTag>> getProductTagVersions({
  1. required String barcode,
  2. required String key,
  3. QueryType? queryType,
})

Returns the versions of ProductTag for this barcode and key.

Implementation

static Future<List<ProductTag>> getProductTagVersions({
  required final String barcode,
  required final String key,
  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/$key/versions',
      queryParameters: parameters,
      queryType: queryType,
    ),
    queryType: queryType,
  );
  _checkResponse(response);
  final List<ProductTag> result = <ProductTag>[];
  if (response.body == 'null') {
    // not found
    return result;
  }
  final List<dynamic> json = jsonDecode(response.body) as List<dynamic>;
  for (var element in json) {
    result.add(ProductTag.fromJson(element));
  }
  return result;
}