forked from eatvio/eatvio_app
feat(notifications): added json parsing for notifications and tested impplementation of notifications layoute
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
abstract class BaseNotificationModel {
|
||||
abstract final NotificationType type;
|
||||
}
|
||||
@@ -18,12 +16,13 @@ class PlanSubscriptionStartedToAuthorNotification implements BaseNotificationMod
|
||||
required this.chatId,
|
||||
});
|
||||
|
||||
factory PlanSubscriptionStartedToAuthorNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory PlanSubscriptionStartedToAuthorNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory PlanSubscriptionStartedToAuthorNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return PlanSubscriptionStartedToAuthorNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['user_name'],
|
||||
chatId: json['chat_id'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +38,12 @@ class PlanSubscriptionCanceledToAuthorNotification implements BaseNotificationMo
|
||||
required this.customerName,
|
||||
});
|
||||
|
||||
factory PlanSubscriptionCanceledToAuthorNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory PlanSubscriptionCanceledToAuthorNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory PlanSubscriptionCanceledToAuthorNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return PlanSubscriptionCanceledToAuthorNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['user_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +59,12 @@ class ChosenPlanStartedToClientNotification implements BaseNotificationModel {
|
||||
required this.planId,
|
||||
});
|
||||
|
||||
factory ChosenPlanStartedToClientNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ChosenPlanStartedToClientNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ChosenPlanStartedToClientNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ChosenPlanStartedToClientNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
planId: json['plan_id'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,12 +78,11 @@ class ChosenPlanTomorrowReminderToClientNotification implements BaseNotification
|
||||
required this.planName,
|
||||
});
|
||||
|
||||
factory ChosenPlanTomorrowReminderToClientNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ChosenPlanTomorrowReminderToClientNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ChosenPlanTomorrowReminderToClientNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ChosenPlanTomorrowReminderToClientNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,12 +92,10 @@ class DiaryReminderNotification implements BaseNotificationModel {
|
||||
|
||||
DiaryReminderNotification({required this.type});
|
||||
|
||||
factory DiaryReminderNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory DiaryReminderNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory DiaryReminderNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return DiaryReminderNotification(
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,12 +109,8 @@ class ConsultantLeftCommentNotification implements BaseNotificationModel {
|
||||
required this.date,
|
||||
});
|
||||
|
||||
factory ConsultantLeftCommentNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ConsultantLeftCommentNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ConsultantLeftCommentNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ConsultantLeftCommentNotification(type: type, date: json['diary_date']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,12 +120,10 @@ class PersonalizedDietIsDefinedNotification implements BaseNotificationModel {
|
||||
|
||||
PersonalizedDietIsDefinedNotification({required this.type});
|
||||
|
||||
factory PersonalizedDietIsDefinedNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory PersonalizedDietIsDefinedNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory PersonalizedDietIsDefinedNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return PersonalizedDietIsDefinedNotification(
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,12 +136,8 @@ class ChosenPlanFinishedToClientNotification implements BaseNotificationModel {
|
||||
required this.planName,
|
||||
});
|
||||
|
||||
factory ChosenPlanFinishedToClientNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ChosenPlanFinishedToClientNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ChosenPlanFinishedToClientNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ChosenPlanFinishedToClientNotification(type: type, planName: json['plan_name']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,12 +150,11 @@ class PlanSubscriptionCanceledToCustomerNotification implements BaseNotification
|
||||
required this.planName,
|
||||
});
|
||||
|
||||
factory PlanSubscriptionCanceledToCustomerNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory PlanSubscriptionCanceledToCustomerNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory PlanSubscriptionCanceledToCustomerNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return PlanSubscriptionCanceledToCustomerNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,12 +169,12 @@ class ChosenPlanStartedToConsultantNotification implements BaseNotificationModel
|
||||
required this.customerName,
|
||||
});
|
||||
|
||||
factory ChosenPlanStartedToConsultantNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ChosenPlanStartedToConsultantNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ChosenPlanStartedToConsultantNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ChosenPlanStartedToConsultantNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['client_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,12 +189,12 @@ class ChosenPlanTomorrowReminderToConsultantNotification implements BaseNotifica
|
||||
required this.customerName,
|
||||
});
|
||||
|
||||
factory ChosenPlanTomorrowReminderToConsultantNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ChosenPlanTomorrowReminderToConsultantNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ChosenPlanTomorrowReminderToConsultantNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ChosenPlanTomorrowReminderToConsultantNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['client_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,12 +209,12 @@ class PlanSubscriptionPaidToAuthorNotification implements BaseNotificationModel
|
||||
required this.customerName,
|
||||
});
|
||||
|
||||
factory PlanSubscriptionPaidToAuthorNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory PlanSubscriptionPaidToAuthorNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory PlanSubscriptionPaidToAuthorNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return PlanSubscriptionPaidToAuthorNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['user_name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,12 +231,13 @@ class ChosenPlanFinishedToConsultantNotification implements BaseNotificationMode
|
||||
required this.planId,
|
||||
});
|
||||
|
||||
factory ChosenPlanFinishedToConsultantNotification.fromRest(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
factory ChosenPlanFinishedToConsultantNotification.fromWebSocket(Map<String, dynamic> json) {
|
||||
throw UnimplementedError();
|
||||
factory ChosenPlanFinishedToConsultantNotification.fromJson(Map<String, dynamic> json, NotificationType type) {
|
||||
return ChosenPlanFinishedToConsultantNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['client_name'],
|
||||
planId: json['plan_id'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user