|
1 | 1 | import 'dart:convert'; |
2 | 2 |
|
3 | | -import 'package:cloudotp/Models/cloud_service_config.dart'; |
4 | | - |
5 | | -import '../../Models/token_category.dart'; |
6 | | -import '../../Models/config.dart'; |
7 | 3 | import '../../Models/opt_token.dart'; |
| 4 | +import '../../Models/token_category.dart'; |
8 | 5 |
|
9 | 6 | class Backup { |
10 | 7 | final List<OtpToken> tokens; |
11 | 8 | final List<TokenCategory> categories; |
12 | | - final Config config; |
13 | | - final List<CloudServiceConfig> cloudServiceConfigs; |
14 | 9 |
|
15 | 10 | String get json => jsonEncode(toJson()); |
16 | 11 |
|
17 | 12 | Backup({ |
18 | 13 | required this.tokens, |
19 | 14 | required this.categories, |
20 | | - required this.cloudServiceConfigs, |
21 | | - required this.config, |
22 | 15 | }); |
23 | 16 |
|
24 | 17 | Map<String, dynamic> toJson() { |
25 | 18 | return { |
26 | 19 | 'tokens': tokens.map((e) => e.toJson()).toList(), |
27 | 20 | 'categories': categories.map((e) => e.toJson()).toList(), |
28 | | - 'cloudServiceConfigs': |
29 | | - cloudServiceConfigs.map((e) => e.toJson()).toList(), |
30 | | - 'config': config.toJson(), |
31 | 21 | }; |
32 | 22 | } |
33 | 23 |
|
34 | 24 | static Backup fromJson(Map<String, dynamic> json) { |
35 | 25 | return Backup( |
36 | | - tokens: json['tokens'] != null |
37 | | - ? (json['tokens'] as List).map((e) => OtpToken.fromJson(e)).toList() |
38 | | - : [], |
39 | | - categories: json['categories'] != null |
40 | | - ? (json['categories'] as List) |
41 | | - .map((e) => TokenCategory.fromJson(e)) |
42 | | - .toList() |
43 | | - : [], |
44 | | - cloudServiceConfigs: json['cloudServiceConfigs'] != null |
45 | | - ? (json['cloudServiceConfigs'] as List) |
46 | | - .map((e) => CloudServiceConfig.fromJson(e)) |
47 | | - .toList() |
48 | | - : [], |
49 | | - config: json['config'] != null |
50 | | - ? Config.fromJson(json['config']) |
51 | | - : Config()); |
| 26 | + tokens: json['tokens'] != null |
| 27 | + ? (json['tokens'] as List).map((e) => OtpToken.fromJson(e)).toList() |
| 28 | + : [], |
| 29 | + categories: json['categories'] != null |
| 30 | + ? (json['categories'] as List) |
| 31 | + .map((e) => TokenCategory.fromJson(e)) |
| 32 | + .toList() |
| 33 | + : [], |
| 34 | + ); |
52 | 35 | } |
53 | | - |
54 | 36 | } |
0 commit comments