toJson method

  1. @override
Map<String, dynamic> toJson()
override

Implementation

@override
Map<String, dynamic> toJson() {
  Map<String, dynamic> json = {};
  Map<String, dynamic> accept = {};
  Map<String, dynamic> vp = {};
  Map<String, dynamic> endpoint = {};

  vp['type'] = _vpType;
  vp['credentialTypes'] = _credentialTypes;
  accept['type'] = _acceptType;
  accept['verifiablePresentation'] = vp;

  if (_requiredProperties != null && _requiredProperties!.isNotEmpty) {
    Map<String, dynamic> sd = {};
    sd['type'] = _selectiveDisclosureType;
    sd['requiredProperties'] = _requiredProperties;
    accept['selectiveDisclosure'] = sd;
  }

  if (_isAppLink!) {
    endpoint['type'] = 'AppLink';
  } else {
    endpoint['type'] = 'WebAddress';
  }
  endpoint['location'] = _location;

  accept['endpoint'] = endpoint;
  json['type'] = _type;
  json['accept'] = accept;
  json['challenge'] = challenge;
  if (_domain != null) {
    json['domain'] = _domain;
    if (_domainSpecificExtension != null &&
        _domainSpecificExtension!.isNotEmpty) {
      json.addAll(_domainSpecificExtension!);
    }
  }

  return json;
}