convertMessage static method

Map convertMessage(
  1. Map<String, dynamic> message
)

Implementation

static Map<dynamic, dynamic> convertMessage(Map<String, dynamic> message) {
  var result = message;
  var data = message["data"]?["data"];
  var messageId = message["data"]?["messageId"];
  var buttonId = message["data"]?["buttonId"];
  var traceId = message["data"]?["mfTraceId"];
  if (traceId != null) {
    result["mfTraceId"] = traceId;
  }
  if (buttonId != null) {
    result["buttonId"] = buttonId;
  }
  if (messageId != null) {
    result["messageId"] = messageId;
  }
  if (data != null) {
    try {
      var tData = json.decode(data);
      result["data"] = tData;
    } catch (_) {
      result["data"] = data;
    }
  }
  return result;
}