postInsightAnnotation static method

Future<Status> postInsightAnnotation(
  1. String? insightId,
  2. InsightAnnotation annotation, {
  3. User? user,
  4. String? deviceId,
  5. bool update = true,
  6. QueryType? queryType,
})

Implementation

static Future<Status> postInsightAnnotation(
  String? insightId,
  InsightAnnotation annotation, {
  User? user,
  String? deviceId,
  bool update = true,
  final QueryType? queryType,
}) async {
  var insightUri = UriHelper.getRobotoffUri(
    path: 'api/v1/insights/annotate',
    queryType: queryType,
  );

  final Map<String, String> annotationData = {
    'annotation': annotation.value.toString(),
    'update': update ? '1' : '0'
  };
  if (insightId != null) {
    annotationData['insight_id'] = insightId;
  }

  if (deviceId != null) {
    annotationData['device_id'] = deviceId;
  }

  Response response = await HttpHelper().doPostRequest(
    insightUri,
    annotationData,
    user,
    queryType: queryType,
    addCredentialsToBody: false,
    addCredentialsToHeader: true,
  );
  return Status.fromApiResponse(response.body);
}