fromJson static method

MmConfigSamlSettings? fromJson(
  1. dynamic value
)

Returns a new MmConfigSamlSettings instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static MmConfigSamlSettings? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "MmConfigSamlSettings[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MmConfigSamlSettings[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MmConfigSamlSettings(
      enable: mapValueOfType<bool>(json, r'Enable'),
      verify: mapValueOfType<bool>(json, r'Verify'),
      encrypt: mapValueOfType<bool>(json, r'Encrypt'),
      idpUrl: mapValueOfType<String>(json, r'IdpUrl'),
      idpDescriptorUrl: mapValueOfType<String>(json, r'IdpDescriptorUrl'),
      assertionConsumerServiceURL: mapValueOfType<String>(json, r'AssertionConsumerServiceURL'),
      idpCertificateFile: mapValueOfType<String>(json, r'IdpCertificateFile'),
      publicCertificateFile: mapValueOfType<String>(json, r'PublicCertificateFile'),
      privateKeyFile: mapValueOfType<String>(json, r'PrivateKeyFile'),
      firstNameAttribute: mapValueOfType<String>(json, r'FirstNameAttribute'),
      lastNameAttribute: mapValueOfType<String>(json, r'LastNameAttribute'),
      emailAttribute: mapValueOfType<String>(json, r'EmailAttribute'),
      usernameAttribute: mapValueOfType<String>(json, r'UsernameAttribute'),
      nicknameAttribute: mapValueOfType<String>(json, r'NicknameAttribute'),
      localeAttribute: mapValueOfType<String>(json, r'LocaleAttribute'),
      positionAttribute: mapValueOfType<String>(json, r'PositionAttribute'),
      loginButtonText: mapValueOfType<String>(json, r'LoginButtonText'),
    );
  }
  return null;
}