fromJson static method

MmConfigEmailSettings? fromJson(
  1. dynamic value
)

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

Implementation

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

    return MmConfigEmailSettings(
      enableSignUpWithEmail: mapValueOfType<bool>(json, r'EnableSignUpWithEmail'),
      enableSignInWithEmail: mapValueOfType<bool>(json, r'EnableSignInWithEmail'),
      enableSignInWithUsername: mapValueOfType<bool>(json, r'EnableSignInWithUsername'),
      sendEmailNotifications: mapValueOfType<bool>(json, r'SendEmailNotifications'),
      requireEmailVerification: mapValueOfType<bool>(json, r'RequireEmailVerification'),
      feedbackName: mapValueOfType<String>(json, r'FeedbackName'),
      feedbackEmail: mapValueOfType<String>(json, r'FeedbackEmail'),
      feedbackOrganization: mapValueOfType<String>(json, r'FeedbackOrganization'),
      sMTPUsername: mapValueOfType<String>(json, r'SMTPUsername'),
      sMTPPassword: mapValueOfType<String>(json, r'SMTPPassword'),
      sMTPServer: mapValueOfType<String>(json, r'SMTPServer'),
      sMTPPort: mapValueOfType<String>(json, r'SMTPPort'),
      connectionSecurity: mapValueOfType<String>(json, r'ConnectionSecurity'),
      inviteSalt: mapValueOfType<String>(json, r'InviteSalt'),
      passwordResetSalt: mapValueOfType<String>(json, r'PasswordResetSalt'),
      sendPushNotifications: mapValueOfType<bool>(json, r'SendPushNotifications'),
      pushNotificationServer: mapValueOfType<String>(json, r'PushNotificationServer'),
      pushNotificationContents: mapValueOfType<String>(json, r'PushNotificationContents'),
      enableEmailBatching: mapValueOfType<bool>(json, r'EnableEmailBatching'),
      emailBatchingBufferSize: mapValueOfType<int>(json, r'EmailBatchingBufferSize'),
      emailBatchingInterval: mapValueOfType<int>(json, r'EmailBatchingInterval'),
    );
  }
  return null;
}