-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.dart
145 lines (118 loc) · 2.83 KB
/
schema.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import 'package:app/const.dart';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
part 'schema.g.dart';
@collection
class User {
Id id = Isar.autoIncrement; // Auto-incremented id
late String? name;
late String? languageCode;
late String? countryCode;
@Enumerated(EnumType.name)
late ThemeMode? theme;
late String? home;
@Enumerated(EnumType.name)
late UserType? type;
late String? userId;
late String? profileId;
late String? authToken;
late String? refreshToken;
late bool? isApproved;
User(
{this.name,
this.authToken,
this.refreshToken,
this.userId,
this.type,
this.profileId,
this.countryCode,
this.languageCode,
this.home,
this.theme,
this.isApproved});
}
@collection
class Device {
Id id = Isar.autoIncrement; // Auto-incremented id
late String token;
late String serial;
@Enumerated(EnumType.name)
late DeviceType type;
late String name;
late String model;
late String version;
late String manufacturer;
Device(
{required this.type,
required this.token,
required this.serial,
required this.manufacturer,
required this.model,
required this.name,
required this.version});
Map<String, dynamic> toJson() {
return {
'device_type': type,
'device_token': token,
'device_serial': serial,
};
}
}
@collection
class Log {
Id id = Isar.autoIncrement; // Auto-incremented id
@Enumerated(EnumType.name)
late UserType userType;
late String userId;
late String userProfileId;
late String deviceSerial;
@Enumerated(EnumType.name)
late DeviceType deviceType;
@Enumerated(EnumType.name)
late LogLevel logLevel;
late String logMsg;
late DateTime logTime;
Log(
{required this.deviceSerial,
required this.deviceType,
required this.logLevel,
required this.logMsg,
required this.userId,
required this.userProfileId,
required this.userType,
required this.logTime});
Map<String, dynamic> toJson() {
return {
'device': {
'type': deviceType.name,
'serial': deviceSerial,
},
'user': {
'id': userId,
'profile_id': userProfileId,
'type': userType.name
},
'log': {'msg': logMsg, 'level': logLevel.name, 'time': logTime}
};
}
}
@collection
class Notification {
Id id = Isar.autoIncrement; // Auto-incremented id
late String msg;
late bool isRead;
@Enumerated(EnumType.name)
late NotificationType type;
late DateTime time;
Notification(
{required this.msg,
required this.isRead,
required this.time,
required this.type});
Notification.fromJson(Map<String, dynamic> data) {
msg = data['msg'];
isRead = data['is_read'] ?? false;
type = data['type'];
time = data['time'];
}
}