toJson method

Map<String, Object?> toJson()

Implementation

Map<String, Object?> toJson() {
  final data = <String, Object?>{};
  data['algorithm'] = algorithm;
  data['sender_key'] = senderKey;
  if (deviceId != null) {
    data['device_id'] = deviceId;
  }
  if (sessionId != null) {
    data['session_id'] = sessionId;
  }
  if (ciphertextMegolm != null) {
    data['ciphertext'] = ciphertextMegolm;
  }
  if (ciphertextOlm != null) {
    data['ciphertext'] =
        ciphertextOlm!.map((k, v) => MapEntry(k, v.toJson()));
    if (ciphertextMegolm != null) {
      Logs().wtf(
          'ciphertextOlm and ciphertextMegolm are both set, which should never happen!');
    }
  }
  return data;
}