createDialogEntity static method

Future<DialogEntity> createDialogEntity(
  1. dynamic dialog,
  2. String appId, {
  3. Feedback? feedback,
})

Implementation

static Future<DialogEntity> createDialogEntity(
  dynamic dialog,
  String appId, {
  Feedback? feedback,
}) async {
  var documentID = dialog['documentID'];
  dialog['appId'] = appId;
  var dialogEntity = DialogEntity.fromMap(dialog);
  if (dialogEntity != null) {
    var newDialogEntity = await dialogRepository(appId: appId)!
        .addEntity(documentID, dialogEntity);
    if (feedback != null) {
      feedback(JsonConsts.dialogs, documentID);
    }
    return newDialogEntity;
  } else {
    throw Exception('Can not create dialogEntity');
  }
}