toJson method

Map<String, dynamic> toJson()

Converts the DIDAuthMessage instance to a JSON map.

Implementation

Map<String, dynamic> toJson() {
  try {
    final Map<String, dynamic> data = {};
    data["id"] = id;
    data["type"] = type;
    data["from"] = from;
    data["to"] = to;
    if (createdTime != null) data["createdTime"] = createdTime;
    if (expiresTime != null) data["expiresTime"] = expiresTime;
    data["body"] = {
      "context": context.toJson(),
      "peerSocketId": peerSocketId,
    };
    if (socketId != null) {
      data["body"]["socketId"] = socketId;
    }
    return data;
  } catch (e) {
    rethrow;
  }
}