-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
365 additions
and
1,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/uni_app/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_api.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
packages/uni_app/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_html.dart
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
packages/uni_app/lib/controller/fetchers/schedule_fetcher/schedule_fetcher_new_api.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:uni/controller/fetchers/schedule_fetcher/schedule_fetcher.dart'; | ||
import 'package:uni/controller/networking/network_router.dart'; | ||
import 'package:uni/controller/parsers/schedule/new_api/parser.dart'; | ||
import 'package:uni/model/entities/lecture.dart'; | ||
import 'package:uni/model/entities/profile.dart'; | ||
import 'package:uni/model/entities/session.dart'; | ||
|
||
/// Class for fetching the user's lectures from the schedule's HTML page. | ||
class ScheduleFetcherNewApi extends ScheduleFetcher { | ||
@override | ||
List<String> getEndpoints(Session session) { | ||
final urls = NetworkRouter.getBaseUrlsFromSession(session) | ||
.map((url) => '${url}hor_geral.estudantes_view') | ||
.toList(); | ||
return urls; | ||
} | ||
|
||
/// Fetches the user's lectures from the schedule's HTML page. | ||
@override | ||
Future<List<Lecture>> getLectures(Session session, Profile profile) async { | ||
final endpoints = getEndpoints(session); | ||
final lectiveYear = getLectiveYear(DateTime.now()); | ||
|
||
final futures = endpoints.map((baseUrl) async { | ||
final scheduleResponse = await NetworkRouter.getWithCookies( | ||
baseUrl, | ||
{ | ||
'pv_num_unico': session.username, | ||
'pv_ano_lectivo': lectiveYear.toString(), | ||
'pv_periodos': '1', | ||
}, | ||
session, | ||
); | ||
|
||
final scheduleApiUrl = getScheduleApiUrlFromHtml(scheduleResponse); | ||
|
||
final scheduleApiResponse = await NetworkRouter.getWithCookies( | ||
scheduleApiUrl, | ||
{}, | ||
session, | ||
); | ||
|
||
return getLecturesFromApiResponse(scheduleApiResponse); | ||
}); | ||
|
||
final results = await Future.wait(futures); | ||
|
||
// TODO(limwa,#1281): Check if handling of lectures in both faculties is correct. | ||
final lectures = results.expand((element) => element).toList() | ||
..sort((l1, l2) => l1.compare(l2)); | ||
|
||
return lectures; | ||
} | ||
} |
183 changes: 0 additions & 183 deletions
183
packages/uni_app/lib/controller/parsers/parser_schedule_html.dart
This file was deleted.
Oops, something went wrong.
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
packages/uni_app/lib/controller/parsers/schedule/new_api/models/response_lecture.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:uni/controller/parsers/schedule/new_api/models/response_lecture_class.dart'; | ||
import 'package:uni/controller/parsers/schedule/new_api/models/response_lecture_person.dart'; | ||
import 'package:uni/controller/parsers/schedule/new_api/models/response_lecture_room.dart'; | ||
import 'package:uni/controller/parsers/schedule/new_api/models/response_lecture_typology.dart'; | ||
import 'package:uni/controller/parsers/schedule/new_api/models/response_lecture_unit.dart'; | ||
|
||
part '../../../../../generated/controller/parsers/schedule/new_api/models/response_lecture.g.dart'; | ||
|
||
@JsonSerializable(explicitToJson: true) | ||
class ResponseLecture { | ||
ResponseLecture( | ||
this.start, | ||
this.end, | ||
this.units, | ||
this.classes, | ||
this.persons, | ||
this.rooms, | ||
this.typology, | ||
); | ||
|
||
factory ResponseLecture.fromJson(Map<String, dynamic> json) => | ||
_$ResponseLectureFromJson(json); | ||
|
||
DateTime start; | ||
DateTime end; | ||
@JsonKey(name: 'ucs') | ||
List<ResponseLectureUnit> units; | ||
List<ResponseLectureClass> classes; | ||
List<ResponseLecturePerson> persons; | ||
List<ResponseLectureRoom> rooms; | ||
ResponseLectureTypology typology; | ||
|
||
Map<String, dynamic> toJson() => _$ResponseLectureToJson(this); | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/uni_app/lib/controller/parsers/schedule/new_api/models/response_lecture_class.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part '../../../../../generated/controller/parsers/schedule/new_api/models/response_lecture_class.g.dart'; | ||
|
||
@JsonSerializable(explicitToJson: true) | ||
class ResponseLectureClass { | ||
ResponseLectureClass(this.acronym); | ||
factory ResponseLectureClass.fromJson(Map<String, dynamic> json) => | ||
_$ResponseLectureClassFromJson(json); | ||
|
||
String acronym; | ||
|
||
Map<String, dynamic> toJson() => _$ResponseLectureClassToJson(this); | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/uni_app/lib/controller/parsers/schedule/new_api/models/response_lecture_person.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part '../../../../../generated/controller/parsers/schedule/new_api/models/response_lecture_person.g.dart'; | ||
|
||
@JsonSerializable(explicitToJson: true) | ||
class ResponseLecturePerson { | ||
ResponseLecturePerson(this.acronym); | ||
factory ResponseLecturePerson.fromJson(Map<String, dynamic> json) => | ||
_$ResponseLecturePersonFromJson(json); | ||
|
||
String acronym; | ||
|
||
Map<String, dynamic> toJson() => _$ResponseLecturePersonToJson(this); | ||
} |
Oops, something went wrong.