sendMessage method

Future<void> sendMessage(
  1. String dialogId, {
  2. String? body,
  3. List<QBAttachment>? attachments,
  4. Map<String, String>? properties,
  5. bool markable = false,
  6. bool? saveToHistory,
})

Implementation

Future<void> sendMessage(String dialogId,
    {String? body,
    List<QBAttachment>? attachments,
    Map<String, String>? properties,
    bool markable = false,
    bool? saveToHistory}) async {
  Map<String, Object> data = Map();

  data["dialogId"] = dialogId;

  data["markable"] = markable;

  if (body != null) {
    data["body"] = body;
  }
  if (attachments != null && attachments.length > 0) {
    List<Map<String, Object>?> attachmentMapList = [];
    for (final attachment in attachments) {
      Map<String, Object>? attachmentMap = QBAttachmentMapper.qbAttachmentToMap(attachment);

      attachmentMapList.add(attachmentMap);
    }
    data["attachments"] = attachmentMapList;
  }
  if (properties != null && properties.length > 0) {
    data["properties"] = properties;
  }
  if (saveToHistory != null) {
    data["saveToHistory"] = saveToHistory;
  }
  await _chatModule.invokeMethod(SEND_MESSAGE_METHOD, data);
}