fromJson static method

MmConfigServiceSettings? fromJson(
  1. dynamic value
)

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

Implementation

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

    return MmConfigServiceSettings(
      siteURL: mapValueOfType<String>(json, r'SiteURL'),
      listenAddress: mapValueOfType<String>(json, r'ListenAddress'),
      connectionSecurity: mapValueOfType<String>(json, r'ConnectionSecurity'),
      tLSCertFile: mapValueOfType<String>(json, r'TLSCertFile'),
      tLSKeyFile: mapValueOfType<String>(json, r'TLSKeyFile'),
      useLetsEncrypt: mapValueOfType<bool>(json, r'UseLetsEncrypt'),
      letsEncryptCertificateCacheFile: mapValueOfType<String>(json, r'LetsEncryptCertificateCacheFile'),
      forward80To443: mapValueOfType<bool>(json, r'Forward80To443'),
      readTimeout: mapValueOfType<int>(json, r'ReadTimeout'),
      writeTimeout: mapValueOfType<int>(json, r'WriteTimeout'),
      maximumLoginAttempts: mapValueOfType<int>(json, r'MaximumLoginAttempts'),
      segmentDeveloperKey: mapValueOfType<String>(json, r'SegmentDeveloperKey'),
      googleDeveloperKey: mapValueOfType<String>(json, r'GoogleDeveloperKey'),
      enableOAuthServiceProvider: mapValueOfType<bool>(json, r'EnableOAuthServiceProvider'),
      enableIncomingWebhooks: mapValueOfType<bool>(json, r'EnableIncomingWebhooks'),
      enableOutgoingWebhooks: mapValueOfType<bool>(json, r'EnableOutgoingWebhooks'),
      enableCommands: mapValueOfType<bool>(json, r'EnableCommands'),
      enableOnlyAdminIntegrations: mapValueOfType<bool>(json, r'EnableOnlyAdminIntegrations'),
      enablePostUsernameOverride: mapValueOfType<bool>(json, r'EnablePostUsernameOverride'),
      enablePostIconOverride: mapValueOfType<bool>(json, r'EnablePostIconOverride'),
      enableTesting: mapValueOfType<bool>(json, r'EnableTesting'),
      enableDeveloper: mapValueOfType<bool>(json, r'EnableDeveloper'),
      enableSecurityFixAlert: mapValueOfType<bool>(json, r'EnableSecurityFixAlert'),
      enableInsecureOutgoingConnections: mapValueOfType<bool>(json, r'EnableInsecureOutgoingConnections'),
      enableMultifactorAuthentication: mapValueOfType<bool>(json, r'EnableMultifactorAuthentication'),
      enforceMultifactorAuthentication: mapValueOfType<bool>(json, r'EnforceMultifactorAuthentication'),
      allowCorsFrom: mapValueOfType<String>(json, r'AllowCorsFrom'),
      sessionLengthWebInDays: mapValueOfType<int>(json, r'SessionLengthWebInDays'),
      sessionLengthMobileInDays: mapValueOfType<int>(json, r'SessionLengthMobileInDays'),
      sessionLengthSSOInDays: mapValueOfType<int>(json, r'SessionLengthSSOInDays'),
      sessionCacheInMinutes: mapValueOfType<int>(json, r'SessionCacheInMinutes'),
      websocketSecurePort: mapValueOfType<int>(json, r'WebsocketSecurePort'),
      websocketPort: mapValueOfType<int>(json, r'WebsocketPort'),
      webserverMode: mapValueOfType<String>(json, r'WebserverMode'),
      enableCustomEmoji: mapValueOfType<bool>(json, r'EnableCustomEmoji'),
      restrictCustomEmojiCreation: mapValueOfType<String>(json, r'RestrictCustomEmojiCreation'),
    );
  }
  return null;
}