RevocationList2020Status.fromJson constructor

RevocationList2020Status.fromJson(
  1. dynamic jsonData
)

Implementation

factory RevocationList2020Status.fromJson(dynamic jsonData) {
  var data = credentialToMap(jsonData);

  String id;
  if (data.containsKey('id')) {
    id = data['id'];
  } else {
    throw FormatException('id property is needed in Credential Status');
  }
  String type;
  if (data.containsKey('type')) {
    type = data['type'];
    if (type != 'RevocationList2020Status') {
      throw Exception('type must be RevocationList2020Status');
    }
  } else {
    throw FormatException('type property is needed in credentialStatus');
  }
  String revocationListIndex;
  if (data.containsKey('revocationListIndex')) {
    revocationListIndex = data['revocationListIndex'];
  } else {
    throw Exception('revocationListIndex needed');
  }

  String revocationListCredential;
  if (data.containsKey('revocationListCredential')) {
    revocationListCredential = data['revocationListCredential'];
  } else {
    throw Exception('revocationListCredential needed');
  }

  return RevocationList2020Status(
      id: id,
      revocationListCredential: revocationListCredential,
      revocationListIndex: revocationListIndex,
      originalData: data);
}