Skip to content

Commit 2fb51b3

Browse files
committed
Added new formatting option
1 parent bb40a00 commit 2fb51b3

File tree

8 files changed

+484
-315
lines changed

8 files changed

+484
-315
lines changed

analysis_options.yaml

Lines changed: 248 additions & 79 deletions
Large diffs are not rendered by default.

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ packages:
7171
path: ".."
7272
relative: true
7373
source: path
74-
version: "1.0.1"
74+
version: "1.0.2"
7575
equatable:
7676
dependency: transitive
7777
description:

lib/src/absence_objects.dart

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'util.dart';
44
/// The actual excuse for an [UntisAbsence], it contains a reference
55
/// to a [UntisExcuseStatus].
66
class UntisExcuse {
7+
UntisExcuse._(this.id, this.excuseStatus, this.text, this.number, this.date);
8+
79
/// ID to track this individual excuse
810
final int id;
911

@@ -19,8 +21,6 @@ class UntisExcuse {
1921
/// The date for when this excuse is valid
2022
final DateTime date;
2123

22-
UntisExcuse._(this.id, this.excuseStatus, this.text, this.number, this.date);
23-
2424
/// Parses this object from [json]
2525
static Future<UntisExcuse> fromJson(
2626
UntisSession s, Map<String, dynamic> json) async {
@@ -40,6 +40,14 @@ class UntisExcuse {
4040
/// This is a general status, that can be used with every [UntisExcuse].
4141
/// [UntisExcuse] is the concrete excuse, which contains a reference to this
4242
class UntisExcuseStatus {
43+
/// Parses this object from [json]
44+
UntisExcuseStatus.fromJson(Map<String, dynamic> json)
45+
: id = json['id'],
46+
name = json['name'],
47+
longName = json['longName'],
48+
excused = json['excused'],
49+
active = json['active'];
50+
4351
/// ID for referred to from a [UntisExcuse]
4452
final int id;
4553

@@ -54,14 +62,6 @@ class UntisExcuseStatus {
5462

5563
/// Unknown what this is, always true?
5664
final bool active;
57-
58-
/// Parses this object from [json]
59-
UntisExcuseStatus.fromJson(Map<String, dynamic> json)
60-
: id = json['id'],
61-
name = json['name'],
62-
longName = json['longName'],
63-
excused = json['excused'],
64-
active = json['active'];
6565
}
6666

6767
/// An absence of a student
@@ -70,6 +70,19 @@ class UntisExcuseStatus {
7070
/// Additionally contains [UntisAbsenceReason] and sometimes a title,
7171
/// for example for a school event.
7272
class UntisAbsence {
73+
UntisAbsence._(
74+
this.id,
75+
this.studentId,
76+
this.classId,
77+
this.startDateTime,
78+
this.endDateTime,
79+
this.owner,
80+
this.excused,
81+
this.excuse,
82+
this.reason,
83+
this.reasonText,
84+
this.text);
85+
7386
/// ID for the individual absence
7487
final int id;
7588

@@ -103,19 +116,6 @@ class UntisAbsence {
103116
/// A title for the absence, for example the title of a school event
104117
final String text;
105118

106-
UntisAbsence._(
107-
this.id,
108-
this.studentId,
109-
this.classId,
110-
this.startDateTime,
111-
this.endDateTime,
112-
this.owner,
113-
this.excused,
114-
this.excuse,
115-
this.reason,
116-
this.reasonText,
117-
this.text);
118-
119119
/// Parses this object from [json]
120120
static Future<UntisAbsence> fromJson(
121121
UntisSession s, Map<String, dynamic> json) async {
@@ -145,6 +145,13 @@ class UntisAbsence {
145145
/// This can be illness, school event, furlough(granted vacation), delay
146146
/// This is a necessity for [UntisAbsence], but [UntisExcuseStatus] is not.
147147
class UntisAbsenceReason {
148+
/// Parses this object from [json]
149+
UntisAbsenceReason.fromJson(Map<String, dynamic> json)
150+
: id = json['id'],
151+
name = json['name'],
152+
longName = json['longName'],
153+
active = json['active'];
154+
148155
/// ID for referred to from a [UntisAbsence]
149156
final int id;
150157

@@ -156,11 +163,4 @@ class UntisAbsenceReason {
156163

157164
/// Unknown what this is, always true?
158165
final bool active;
159-
160-
/// Parses this object from [json]
161-
UntisAbsenceReason.fromJson(Map<String, dynamic> json)
162-
: id = json['id'],
163-
name = json['name'],
164-
longName = json['longName'],
165-
active = json['active'];
166166
}

lib/src/auth.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import 'package:crypto/crypto.dart';
77
// ignore_for_file: public_member_api_docs
88

99
class UntisAuthentication {
10+
/// This constructor uses [DateTime.now()] to calculate an opt code
11+
UntisAuthentication.currentTime(String? username, String? appSharedSecret)
12+
: _username = username ?? _defaultUser {
13+
_clientTime = DateTime.now().millisecondsSinceEpoch;
14+
_otp = _createTimeBasedCode(_clientTime, appSharedSecret);
15+
}
16+
1017
static const String _defaultUser = '#anonymous#';
1118

1219
final String _username;
@@ -19,13 +26,6 @@ class UntisAuthentication {
1926
'clientTime': _clientTime
2027
};
2128

22-
/// This constructor uses [DateTime.now()] to calculate an opt code
23-
UntisAuthentication.currentTime(String? username, String? appSharedSecret)
24-
: _username = username ?? _defaultUser {
25-
_clientTime = DateTime.now().millisecondsSinceEpoch;
26-
_otp = _createTimeBasedCode(_clientTime, appSharedSecret);
27-
}
28-
2929
static int _verifyCode(Uint8List key, int time) {
3030
int j = time; // time is the initialization vector
3131
final List<int> arrayOfByte = List<int>.filled(8, 0);

0 commit comments

Comments
 (0)