getRandomInsights static method
Implementation
static Future<InsightsResult> getRandomInsights({
InsightType? type,
Iterable<OpenFoodFactsCountry>? countries,
String? valueTag,
ServerType? serverType,
int? count,
final UriHelper uriHelper = uriHelperRobotoffProd,
}) async {
final Map<String, String> parameters = {
if (type != null) 'type': type.offTag,
if (countries?.isNotEmpty == true)
'countries': _getCountryList(countries!),
if (valueTag != null) 'value_tag': valueTag,
if (count != null) 'count': count.toString(),
if (serverType != null) 'server_type': serverType.offTag,
};
var insightUri = uriHelper.getUri(
path: 'api/v1/insights/random/',
queryParameters: parameters,
);
Response response = await HttpHelper().doGetRequest(
insightUri,
uriHelper: uriHelper,
);
var result = InsightsResult.fromJson(
HttpHelper().jsonDecode(utf8.decode(response.bodyBytes)),
);
return result;
}