initial commit: push everything
This commit is contained in:
139
lib/Models/notification/notification_models.dart
Normal file
139
lib/Models/notification/notification_models.dart
Normal file
@@ -0,0 +1,139 @@
|
||||
// Consolidated notification models
|
||||
|
||||
class AdminNotification {
|
||||
String? priority;
|
||||
List<String>? registrationIds;
|
||||
String? accessid;
|
||||
String? title;
|
||||
String? body;
|
||||
String? sound;
|
||||
|
||||
AdminNotification({
|
||||
this.priority,
|
||||
this.registrationIds,
|
||||
this.accessid,
|
||||
this.title,
|
||||
this.body,
|
||||
this.sound,
|
||||
});
|
||||
|
||||
factory AdminNotification.fromJson(Map<String, dynamic> json) {
|
||||
return AdminNotification(
|
||||
priority: json['priority'] as String?,
|
||||
registrationIds: json['registration_ids']?.cast<String>(),
|
||||
accessid: json['data']?['accessid'] as String?,
|
||||
title: json['notification']?['title'] as String?,
|
||||
body: json['notification']?['body'] as String?,
|
||||
sound: json['notification']?['sound'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['priority'] = priority;
|
||||
data['registration_ids'] = registrationIds;
|
||||
if (accessid != null) {
|
||||
data['data'] = <String, dynamic>{'accessid': accessid};
|
||||
}
|
||||
if (title != null || body != null || sound != null) {
|
||||
data['notification'] = <String, dynamic>{
|
||||
if (title != null) 'title': title,
|
||||
if (body != null) 'body': body,
|
||||
if (sound != null) 'sound': sound,
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class NotificationMessage {
|
||||
String? sender;
|
||||
String? accessid;
|
||||
String? priority;
|
||||
String? to;
|
||||
String? title;
|
||||
String? body;
|
||||
String? sound;
|
||||
|
||||
NotificationMessage({
|
||||
this.sender,
|
||||
this.accessid,
|
||||
this.priority,
|
||||
this.to,
|
||||
this.title,
|
||||
this.body,
|
||||
this.sound,
|
||||
});
|
||||
|
||||
factory NotificationMessage.fromJson(Map<String, dynamic> json) {
|
||||
return NotificationMessage(
|
||||
sender: json['sender'] as String?,
|
||||
accessid: json['accessid'] as String?,
|
||||
priority: json['notification']?['priority'] as String?,
|
||||
to: json['notification']?['to'] as String?,
|
||||
title: json['notification']?['notification']?['title'] as String?,
|
||||
body: json['notification']?['notification']?['body'] as String?,
|
||||
sound: json['notification']?['notification']?['sound'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['sender'] = sender;
|
||||
data['accessid'] = accessid;
|
||||
if (priority != null || to != null || title != null || body != null || sound != null) {
|
||||
data['notification'] = <String, dynamic>{
|
||||
if (priority != null) 'priority': priority,
|
||||
if (to != null) 'to': to,
|
||||
if (title != null || body != null || sound != null) 'notification': <String, dynamic>{
|
||||
if (title != null) 'title': title,
|
||||
if (body != null) 'body': body,
|
||||
if (sound != null) 'sound': sound,
|
||||
},
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class RiderNotification {
|
||||
String? token;
|
||||
String? title;
|
||||
String? body;
|
||||
String? sound;
|
||||
String? image;
|
||||
|
||||
RiderNotification({
|
||||
this.token,
|
||||
this.title,
|
||||
this.body,
|
||||
this.sound,
|
||||
this.image,
|
||||
});
|
||||
|
||||
factory RiderNotification.fromJson(Map<String, dynamic> json) {
|
||||
return RiderNotification(
|
||||
token: json['token'] as String?,
|
||||
title: json['notification']?['title'] as String?,
|
||||
body: json['notification']?['body'] as String?,
|
||||
sound: json['notification']?['sound'] as String?,
|
||||
image: json['notification']?['image'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['token'] = token;
|
||||
if (title != null || body != null || sound != null || image != null) {
|
||||
data['notification'] = <String, dynamic>{
|
||||
if (title != null) 'title': title,
|
||||
if (body != null) 'body': body,
|
||||
if (sound != null) 'sound': sound,
|
||||
if (image != null) 'image': image,
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user