Skip to content

Commit 2b7ff22

Browse files
author
Luis Ciber
committed
Nauta Session Sources
1 parent 397fa25 commit 2b7ff22

File tree

8 files changed

+135
-8
lines changed

8 files changed

+135
-8
lines changed

file_structure.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ lib/
3838
│   │   ├── datasources
3939
│   │   │   ├── datasources.dart
4040
│   │   │   ├── nauta
41-
│   │   │   │   └── nauta_account_datasource.dart
41+
│   │   │   │   ├── nauta_account_datasource.dart
42+
│   │   │   │   ├── nauta.dart
43+
│   │   │   │   └── nauta_session_local_datasource.dart
4244
│   │   │   └── ussd
4345
│   │   │   ├── ussd_assets_datasource.dart
4446
│   │   │   ├── ussd.dart
@@ -49,7 +51,9 @@ lib/
4951
│   │   │   ├── models.dart
5052
│   │   │   ├── nauta
5153
│   │   │   │   ├── nauta_account.dart
52-
│   │   │   │   └── nauta_account.g.dart
54+
│   │   │   │   ├── nauta_account.g.dart
55+
│   │   │   │   ├── nauta_session.dart
56+
│   │   │   │   └── nauta_session.g.dart
5357
│   │   │   └── ussd
5458
│   │   │   ├── category
5559
│   │   │   │   ├── ussd_category.dart
@@ -181,4 +185,4 @@ lib/
181185
├── ussd_item_widget.dart
182186
└── widgets.dart
183187

184-
51 directories, 130 files
188+
51 directories, 134 files
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export 'nauta/nauta_account_datasource.dart';
1+
export 'nauta/nauta.dart';
22
export 'ussd/ussd.dart';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export 'nauta_account_datasource.dart';
2+
export 'nauta_session_local_datasource.dart';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'dart:convert';
2+
3+
import 'package:injectable/injectable.dart';
4+
import 'package:shared_preferences/shared_preferences.dart';
5+
import 'package:todo/app/app.dart';
6+
import 'package:todo/app/data/models/nauta/nauta_session.dart';
7+
8+
const NAUTA_SESSION_KEY = 'NAUTA_SESSION';
9+
10+
@injectable
11+
class NautaSessionLocalDataSource {
12+
NautaSessionLocalDataSource(this._storage);
13+
14+
final SharedPreferences _storage;
15+
16+
Future<void> saveSession(NautaSession session) async {
17+
final data = json.encode(session.toJson());
18+
19+
await _storage.setString(NAUTA_SESSION_KEY, data);
20+
}
21+
22+
Future<NautaSession?> getSession() async {
23+
final jsonString = _storage.getString(NAUTA_SESSION_KEY);
24+
25+
if (jsonString != null) {
26+
final parsedJson = await parseJson(jsonString);
27+
28+
return NautaSession.fromJson(parsedJson);
29+
}
30+
}
31+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:json_annotation/json_annotation.dart';
3+
4+
part 'nauta_session.g.dart';
5+
6+
@JsonSerializable()
7+
class NautaSession extends Equatable {
8+
const NautaSession({
9+
required this.loginAction,
10+
required this.csrfhw,
11+
required this.wlanuserip,
12+
required this.attributeUuid,
13+
required this.ssid,
14+
required this.loggerId,
15+
});
16+
17+
factory NautaSession.fromJson(Map<String, dynamic> json) =>
18+
_$NautaSessionFromJson(json);
19+
20+
final String loginAction;
21+
final String csrfhw;
22+
final String wlanuserip;
23+
final String attributeUuid;
24+
final String ssid;
25+
final String loggerId;
26+
27+
Map<String, dynamic> toJson() => _$NautaSessionToJson(this);
28+
29+
NautaSession copyWith({
30+
String? loginAction,
31+
String? csrfhw,
32+
String? wlanuserip,
33+
String? attributeUuid,
34+
String? ssid,
35+
String? loggerId,
36+
}) =>
37+
NautaSession(
38+
loginAction: loginAction ?? this.loginAction,
39+
csrfhw: csrfhw ?? this.csrfhw,
40+
wlanuserip: wlanuserip ?? this.wlanuserip,
41+
attributeUuid: attributeUuid ?? this.attributeUuid,
42+
ssid: ssid ?? this.ssid,
43+
loggerId: loggerId ?? this.loggerId,
44+
);
45+
46+
@override
47+
List<Object?> get props => [
48+
loginAction,
49+
csrfhw,
50+
wlanuserip,
51+
attributeUuid,
52+
ssid,
53+
loggerId,
54+
];
55+
}

lib/app/data/models/nauta/nauta_session.g.dart

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/app/dependencies/dependencies.config.dart

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lines_of_code.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
41 lib/app/app_environment.dart
5454
17 lib/app/app_bloc_observer.dart
5555
56 lib/app/app.dart
56-
79 lib/app/dependencies/dependencies.config.dart
56+
82 lib/app/dependencies/dependencies.config.dart
5757
36 lib/app/dependencies/dependencies.dart
5858
13 lib/app/data/core/utils/parse_json.dart
5959
2 lib/app/data/core/utils/utils.dart
@@ -70,6 +70,8 @@
7070
42 lib/app/data/core/platform/platform_channels.dart
7171
305 lib/app/data/core/result/result.freezed.dart
7272
9 lib/app/data/core/result/result.dart
73+
2 lib/app/data/datasources/nauta/nauta.dart
74+
31 lib/app/data/datasources/nauta/nauta_session_local_datasource.dart
7375
85 lib/app/data/datasources/nauta/nauta_account_datasource.dart
7476
2 lib/app/data/datasources/datasources.dart
7577
62 lib/app/data/datasources/ussd/ussd_local_datasource.dart
@@ -81,7 +83,9 @@
8183
25 lib/app/data/repositories/nauta_repository.dart
8284
102 lib/app/data/repositories/ussd_repository.dart
8385
29 lib/app/data/models/nauta/nauta_account.dart
86+
55 lib/app/data/models/nauta/nauta_session.dart
8487
22 lib/app/data/models/nauta/nauta_account.g.dart
88+
28 lib/app/data/models/nauta/nauta_session.g.dart
8589
2 lib/app/data/models/models.dart
8690
26 lib/app/data/models/ussd/category/ussd_category.g.dart
8791
65 lib/app/data/models/ussd/category/ussd_category.dart
@@ -126,4 +130,4 @@
126130
2 lib/home/router/router.dart
127131
15 lib/home/router/home_location.dart
128132
22 lib/home/router/home_page.dart
129-
6613 total
133+
6732 total

0 commit comments

Comments
 (0)