InputDescriptorConstraints.fromJson constructor
InputDescriptorConstraints.fromJson(
- dynamic constraintsJson
Implementation
InputDescriptorConstraints.fromJson(dynamic constraintsJson) {
var constraints = credentialToMap(constraintsJson);
if (constraints.containsKey('limit_disclosure')) {
var ld = constraints['limit_disclosure'];
if (ld == 'required') {
limitDisclosure = Limiting.required;
} else if (ld == 'preferred') {
limitDisclosure = Limiting.preferred;
} else {
throw Exception('Unknown value in limit_disclosure');
}
}
if (constraints.containsKey('fields')) {
fields = [];
List tmp = constraints['fields'];
if (tmp.isNotEmpty) {
for (var f in tmp) {
fields!.add(InputDescriptorField.fromJson(f));
}
}
}
if (constraints.containsKey('subject_is_issuer')) {
String sii = constraints['subject_is_issuer'];
if (sii == 'required') {
subjectIsIssuer = Limiting.required;
} else if (sii == 'preferred') {
subjectIsIssuer = Limiting.preferred;
} else {
throw Exception('Unknown value in limit_disclosure');
}
}
if (constraints.containsKey('is_holder')) {
isHolder = HolderSubjectConstraint.fromJson(constraints['is_holder']);
}
if (constraints.containsKey('same_subject')) {
sameSubject =
HolderSubjectConstraint.fromJson(constraints['same_subject']);
}
if (constraints.containsKey('statuses')) {
statuses = StatusObject.fromJson(constraints['status']);
}
}