Files
eatvio_app/lib/features/notifications/models/notification_model.dart

299 lines
9.4 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
abstract class BaseNotificationModel {
abstract final NotificationType type;
}
class PlanSubscriptionStartedToAuthorNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final String customerName;
final String chatId;
PlanSubscriptionStartedToAuthorNotification({
required this.type,
required this.planName,
required this.customerName,
required this.chatId,
});
factory PlanSubscriptionStartedToAuthorNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory PlanSubscriptionStartedToAuthorNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class PlanSubscriptionCanceledToAuthorNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final String customerName;
PlanSubscriptionCanceledToAuthorNotification({
required this.type,
required this.planName,
required this.customerName,
});
factory PlanSubscriptionCanceledToAuthorNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory PlanSubscriptionCanceledToAuthorNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ChosenPlanStartedToClientNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final int planId;
ChosenPlanStartedToClientNotification({
required this.type,
required this.planName,
required this.planId,
});
factory ChosenPlanStartedToClientNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ChosenPlanStartedToClientNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ChosenPlanTomorrowReminderToClientNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
ChosenPlanTomorrowReminderToClientNotification({
required this.type,
required this.planName,
});
factory ChosenPlanTomorrowReminderToClientNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ChosenPlanTomorrowReminderToClientNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class DiaryReminderNotification implements BaseNotificationModel {
@override
final NotificationType type;
DiaryReminderNotification({required this.type});
factory DiaryReminderNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory DiaryReminderNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ConsultantLeftCommentNotification implements BaseNotificationModel {
@override
final NotificationType type;
final DateTime date;
ConsultantLeftCommentNotification({
required this.type,
required this.date,
});
factory ConsultantLeftCommentNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ConsultantLeftCommentNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class PersonalizedDietIsDefinedNotification implements BaseNotificationModel {
@override
final NotificationType type;
PersonalizedDietIsDefinedNotification({required this.type});
factory PersonalizedDietIsDefinedNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory PersonalizedDietIsDefinedNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ChosenPlanFinishedToClientNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
ChosenPlanFinishedToClientNotification({
required this.type,
required this.planName,
});
factory ChosenPlanFinishedToClientNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ChosenPlanFinishedToClientNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class PlanSubscriptionCanceledToCustomerNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
PlanSubscriptionCanceledToCustomerNotification({
required this.type,
required this.planName,
});
factory PlanSubscriptionCanceledToCustomerNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory PlanSubscriptionCanceledToCustomerNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ChosenPlanStartedToConsultantNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final String customerName;
ChosenPlanStartedToConsultantNotification({
required this.type,
required this.planName,
required this.customerName,
});
factory ChosenPlanStartedToConsultantNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ChosenPlanStartedToConsultantNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ChosenPlanTomorrowReminderToConsultantNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final String customerName;
ChosenPlanTomorrowReminderToConsultantNotification({
required this.type,
required this.planName,
required this.customerName,
});
factory ChosenPlanTomorrowReminderToConsultantNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ChosenPlanTomorrowReminderToConsultantNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class PlanSubscriptionPaidToAuthorNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final String customerName;
PlanSubscriptionPaidToAuthorNotification({
required this.type,
required this.planName,
required this.customerName,
});
factory PlanSubscriptionPaidToAuthorNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory PlanSubscriptionPaidToAuthorNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class ChosenPlanFinishedToConsultantNotification implements BaseNotificationModel {
@override
final NotificationType type;
final String planName;
final String customerName;
final int planId;
ChosenPlanFinishedToConsultantNotification({
required this.type,
required this.planName,
required this.customerName,
required this.planId,
});
factory ChosenPlanFinishedToConsultantNotification.fromRest(Map<String, dynamic> json) {
throw UnimplementedError();
}
factory ChosenPlanFinishedToConsultantNotification.fromWebSocket(Map<String, dynamic> json) {
throw UnimplementedError();
}
}
class UnknownNotification implements BaseNotificationModel {
@override
final NotificationType type;
UnknownNotification({
required this.type,
});
}
enum NotificationType {
planSubscriptionStartedToAuthor,
planSubscriptionCanceledToAuthor,
chosenPlanStartedToClientNotification,
chosenPlanTomorrowReminderToClientNotification,
diaryReminderNotification,
consultantLeftComment,
personalizedDietIsDefined,
chosenPlanFinishedToClient,
planSubscriptionCanceledToCustomer,
chosenPlanStartedToConsultantNotification,
chosenPlanTomorrowReminderToConsultantNotification,
planSubscriptionPaidToAuthor,
chosenPlanFinishedToConsultant,
unknown;
static NotificationType getTypeFromString(String type) => switch (type) {
'App\\Notifications\\Plan\\PlanSubscriptionStartedToAuthor' => NotificationType.planSubscriptionStartedToAuthor,
'App\\Notifications\\Plan\\PlanSubscriptionCanceledToAuthor' => NotificationType.planSubscriptionCanceledToAuthor,
'App\\Notifications\\Plan\\ChosenPlanStartedToClientNotification' => NotificationType.chosenPlanStartedToClientNotification,
'App\\Notifications\\Plan\\ChosenPlanTomorrowReminderToClientNotification' => NotificationType.chosenPlanStartedToClientNotification,
'App\\Notifications\\DiaryReminderNotification' => NotificationType.diaryReminderNotification,
'App\\Notifications\\Plan\\ConsultantLeftComment' => NotificationType.consultantLeftComment,
'App\\Notifications\\Plan\\PersonalizedDietIsDefined' => NotificationType.personalizedDietIsDefined,
'App\\Notifications\\Plan\\ChosenPlanFinishedToClient' => NotificationType.chosenPlanFinishedToClient,
'App\\Notifications\\Plan\\PlanSubscriptionCanceledToCustomer' => NotificationType.planSubscriptionCanceledToCustomer,
'App\\Notifications\\Plan\\ChosenPlanStartedToConsultantNotification' => NotificationType.chosenPlanStartedToConsultantNotification,
'App\\Notifications\\Plan\\ChosenPlanTomorrowReminderToConsultantNotification' => NotificationType.chosenPlanTomorrowReminderToConsultantNotification,
'App\\Notifications\\Plan\\PlanSubscriptionPaidToAuthor' => NotificationType.planSubscriptionPaidToAuthor,
'App\\Notifications\\Plan\\ChosenPlanFinishedToConsultant' => NotificationType.chosenPlanFinishedToConsultant,
_ => NotificationType.unknown,
};
}