DIDAuthFailedMessage.fromJson constructor

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

Constructs a DIDAuthFailedMessage instance from a JSON object.

Implementation

factory DIDAuthFailedMessage.fromJson(Map<String, dynamic> json) {
  try {
    if (json.containsKey("type") && json["type"] != "DIDAuthFailed") {
      throw Exception("Invalid type");
    }
    return DIDAuthFailedMessage(
      id: json["id"],
      from: json["from"],
      to: json["to"],
      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"]),
      reason: json["body"]["reason"],
    );
  } catch (e) {
    rethrow;
  }
}