recommendProducts method

Future<List<Product>> recommendProducts({
  1. required Logic logic,
  2. List<RecommendationFilter>? filters,
  3. int? limit,
  4. String? availabilityZone,
})

Implementation

Future<List<Product>> recommendProducts(
    {required Logic logic,
    List<RecommendationFilter>? filters,
    int? limit,
    String? availabilityZone}) async {
  Map<String, dynamic> attributes = {"logic": _logicMapper.map(logic)};
  if (filters != null) {
    attributes["recommendationFilter"] =
        _recommendationFilterListMapper.map(filters);
  }
  if (limit != null) {
    attributes["limit"] = limit;
  }
  if (availabilityZone != null) {
    attributes["availabilityZone"] = availabilityZone;
  }
  List<dynamic>? products =
      await _channel.invokeMethod('predict.recommendProducts', attributes);
  if (products == null) {
    throw TypeError();
  }
  return _productMapper.map(products);
}