postInsightAnnotation static method

Future<Status> postInsightAnnotation(
  1. String? insightId,
  2. InsightAnnotation annotation,
  3. {String? deviceId,
  4. bool update = true,
  5. UriHelper uriHelper = uriHelperRobotoffProd}
)

Implementation

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

  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,
    null,
    uriHelper: uriHelper,
    addCredentialsToBody: false,
    addCredentialsToHeader: true,
  );
  return Status.fromApiResponse(response.body);
}