fromJson static method

MmConfigLdapSettings? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static MmConfigLdapSettings? 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 "MmConfigLdapSettings[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MmConfigLdapSettings[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MmConfigLdapSettings(
      enable: mapValueOfType<bool>(json, r'Enable'),
      ldapServer: mapValueOfType<String>(json, r'LdapServer'),
      ldapPort: mapValueOfType<int>(json, r'LdapPort'),
      connectionSecurity: mapValueOfType<String>(json, r'ConnectionSecurity'),
      baseDN: mapValueOfType<String>(json, r'BaseDN'),
      bindUsername: mapValueOfType<String>(json, r'BindUsername'),
      bindPassword: mapValueOfType<String>(json, r'BindPassword'),
      userFilter: mapValueOfType<String>(json, r'UserFilter'),
      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'),
      idAttribute: mapValueOfType<String>(json, r'IdAttribute'),
      positionAttribute: mapValueOfType<String>(json, r'PositionAttribute'),
      syncIntervalMinutes: mapValueOfType<int>(json, r'SyncIntervalMinutes'),
      skipCertificateVerification: mapValueOfType<bool>(json, r'SkipCertificateVerification'),
      queryTimeout: mapValueOfType<int>(json, r'QueryTimeout'),
      maxPageSize: mapValueOfType<int>(json, r'MaxPageSize'),
      loginFieldName: mapValueOfType<String>(json, r'LoginFieldName'),
    );
  }
  return null;
}