toJson method

dynamic toJson()

Implementation

toJson() {
  var dataToSend;
  if (type == MessageType.text.name ||
      type == MessageType.button.name ||
      type == MessageType.media.name ||
      type == MessageType.file.name) {
    dataToSend = data!.map((e) => e.toJson()).toList()[0];
  } else {
    dataToSend = data!.map((e) => e.toJson()).toList();
  }

  return {
    'senderId': senderId,
    'createdAt': createdAt,
    'type': type,
    'integrationId': integrationId,
    'sessionId': sessionUuid,
    'data': dataToSend,
  };
}