Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions lib/src/fixtures/remote_configs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,6 @@ final List<RemoteConfig> remoteConfigsFixturesData = [
pushNotificationConfig: const PushNotificationConfig(
enabled: true,
primaryProvider: PushNotificationProvider.firebase,
providerConfigs: {
PushNotificationProvider.firebase: FirebaseProviderConfig(
projectId: 'your-firebase-project-id',
clientEmail: 'your-firebase-client-email',
privateKey: 'your-firebase-private-key',
),
PushNotificationProvider.oneSignal: OneSignalProviderConfig(
appId: 'your-onesignal-app-id',
restApiKey: 'your-onesignal-rest-api-key',
),
},
deliveryConfigs: {
PushNotificationSubscriptionDeliveryType.breakingOnly:
PushNotificationDeliveryConfig(
Expand Down
3 changes: 0 additions & 3 deletions lib/src/models/config/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ export 'feed_ad_configuration.dart';
export 'feed_ad_frequency_config.dart';
export 'feed_decorator_config.dart';
export 'feed_decorator_role_config.dart';
export 'firebase_provider_config.dart';
export 'interstitial_ad_configuration.dart';
export 'interstitial_ad_frequency_config.dart';
export 'one_signal_provider_config.dart';
export 'push_notification_config.dart';
export 'push_notification_delivery_config.dart';
export 'push_notification_delivery_role_config.dart';
export 'push_notification_provider_config.dart';
export 'remote_config.dart';
export 'user_preference_config.dart';
59 changes: 0 additions & 59 deletions lib/src/models/config/firebase_provider_config.dart

This file was deleted.

26 changes: 0 additions & 26 deletions lib/src/models/config/firebase_provider_config.g.dart

This file was deleted.

48 changes: 0 additions & 48 deletions lib/src/models/config/one_signal_provider_config.dart

This file was deleted.

24 changes: 0 additions & 24 deletions lib/src/models/config/one_signal_provider_config.g.dart

This file was deleted.

56 changes: 3 additions & 53 deletions lib/src/models/config/push_notification_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ part 'push_notification_config.g.dart';
/// Defines the global configuration for the push notification system.
///
/// This model is part of the overall `RemoteConfig` and allows for remotely
/// managing all aspects of push notifications, including provider credentials,
/// feature availability, and user-specific limits.
/// managing all aspects of push notifications, including feature availability
/// and user-specific limits.
/// {@endtemplate}
@immutable
@JsonSerializable(explicitToJson: true, includeIfNull: true, checked: true)
Expand All @@ -20,7 +20,6 @@ class PushNotificationConfig extends Equatable {
const PushNotificationConfig({
required this.enabled,
required this.primaryProvider,
required this.providerConfigs,
required this.deliveryConfigs,
});

Expand All @@ -38,15 +37,6 @@ class PushNotificationConfig extends Equatable {
/// This allows for dynamically switching between providers like Firebase
final PushNotificationProvider primaryProvider;

/// A map holding the credentials for each potential push provider.
///
/// This uses custom fromJson/toJson helpers to handle the polymorphic nature
/// of [PushNotificationProviderConfig] within a map structure, which is not
/// natively supported by `json_serializable`.
@JsonKey(fromJson: _providerConfigsFromJson, toJson: _providerConfigsToJson)
final Map<PushNotificationProvider, PushNotificationProviderConfig>
providerConfigs;

/// A map to globally enable or disable each specific notification type
/// and define its role-based limits using the `visibleTo` pattern.
final Map<
Expand All @@ -58,53 +48,14 @@ class PushNotificationConfig extends Equatable {
/// Converts this [PushNotificationConfig] instance to JSON data.
Map<String, dynamic> toJson() => _$PushNotificationConfigToJson(this);

/// A custom deserializer for the `providerConfigs` map.
///
/// This function manually iterates through the incoming JSON map, converting
/// string keys into [PushNotificationProvider] enum values and delegating
/// the value deserialization to the polymorphic
/// [PushNotificationProviderConfig.fromJson] factory.
static Map<PushNotificationProvider, PushNotificationProviderConfig>
_providerConfigsFromJson(Map<String, dynamic> json) {
return json.map((key, value) {
final provider = PushNotificationProvider.values.byName(key);
return MapEntry(
provider,
PushNotificationProviderConfig.fromJson(value as Map<String, dynamic>),
);
});
}

/// A custom serializer for the `providerConfigs` map.
///
/// This function manually iterates through the map, converting the
/// [PushNotificationProvider] enum keys into strings and delegating the
/// value serialization to the polymorphic
/// [PushNotificationProviderConfig.toJson] static method.
static Map<String, dynamic> _providerConfigsToJson(
Map<PushNotificationProvider, PushNotificationProviderConfig> configs,
) {
return configs.map(
(key, value) =>
MapEntry(key.name, PushNotificationProviderConfig.toJson(value)),
);
}

@override
List<Object> get props => [
enabled,
primaryProvider,
providerConfigs,
deliveryConfigs,
];
List<Object> get props => [enabled, primaryProvider, deliveryConfigs];

/// Creates a copy of this [PushNotificationConfig] but with the given fields
/// replaced with the new values.
PushNotificationConfig copyWith({
bool? enabled,
PushNotificationProvider? primaryProvider,
Map<PushNotificationProvider, PushNotificationProviderConfig>?
providerConfigs,
Map<
PushNotificationSubscriptionDeliveryType,
PushNotificationDeliveryConfig
Expand All @@ -114,7 +65,6 @@ class PushNotificationConfig extends Equatable {
return PushNotificationConfig(
enabled: enabled ?? this.enabled,
primaryProvider: primaryProvider ?? this.primaryProvider,
providerConfigs: providerConfigs ?? this.providerConfigs,
deliveryConfigs: deliveryConfigs ?? this.deliveryConfigs,
);
}
Expand Down
9 changes: 0 additions & 9 deletions lib/src/models/config/push_notification_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 0 additions & 71 deletions lib/src/models/config/push_notification_provider_config.dart

This file was deleted.

Loading
Loading