DIDConnectRequestMessage.fromJson constructor

DIDConnectRequestMessage.fromJson(
  1. Map<String, dynamic> json
)

Constructs a DIDConnectRequestMessage instance from a JSON map.

The json parameter specifies the JSON map to construct the message from.

Implementation

factory DIDConnectRequestMessage.fromJson(Map<String, dynamic> json) {
  try {
    if (json.containsKey("type") && json["type"] != "DIDConnectReq") {
      throw Exception("Invalid type");
    }
    return DIDConnectRequestMessage(
      from: json["from"],
      createdTime: json.containsKey("createdTime") ? json["createdTime"] : 0,
      expiresTime: json.containsKey("expiresTime") ? json["expiresTime"] : 0,
      context: json["body"].containsKey("context")
          ? Context.fromJson(json["body"]["context"])
          : Context.fromCompactJson(json["body"]["c"]),
      initiator: json["body"].containsKey("initiator")
          ? Initiator.fromJson(json["body"]["initiator"])
          : Initiator.fromCompactJson(json["body"]["i"]),
    );
  } catch (e) {
    rethrow;
  }
}