getRobotoffQuestionsForProduct static method

Future<RobotoffQuestionResult> getRobotoffQuestionsForProduct(
  1. String barcode,
  2. String lang, {
  3. User? user,
  4. int? count,
  5. QueryType? queryType,
})

Implementation

static Future<RobotoffQuestionResult> getRobotoffQuestionsForProduct(
  String barcode,
  String lang, {
  User? user,
  int? count,
  QueryType? queryType,
}) async {
  if (count == null || count <= 0) {
    count = 1;
  }

  final Map<String, String> parameters = <String, String>{
    'lang': lang,
    'count': count.toString()
  };

  var robotoffQuestionUri = UriHelper.getRobotoffUri(
    path: 'api/v1/questions/$barcode',
    queryParameters: parameters,
    queryType: queryType,
  );

  Response response = await HttpHelper().doGetRequest(
    robotoffQuestionUri,
    user: user,
    queryType: queryType,
  );
  var result = RobotoffQuestionResult.fromJson(
      json.decode(utf8.decode(response.bodyBytes)));

  return result;
}