toJson method

Map<String, dynamic> toJson()

Converts the DIDAuthInitMessage instance to a JSON object.

Returns a map representing the JSON object. Throws an exception if an error occurs during the conversion.

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(),
      "socketId": socketId,
      "peerSocketId": peerSocketId,
    };
    return data;
  } catch (e) {
    rethrow;
  }
}