Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/move ets api client #1001

Merged
merged 16 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ PODS:
- Flutter
- flutter_custom_tabs_ios (2.0.0):
- Flutter
- flutter_keychain (0.0.1):
- Flutter
- flutter_secure_storage (6.0.0):
- Flutter
- fluttertoast (0.0.2):
Expand Down Expand Up @@ -209,7 +207,6 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_config (from `.symlinks/plugins/flutter_config/ios`)
- flutter_custom_tabs_ios (from `.symlinks/plugins/flutter_custom_tabs_ios/ios`)
- flutter_keychain (from `.symlinks/plugins/flutter_keychain/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
Expand Down Expand Up @@ -268,8 +265,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_config/ios"
flutter_custom_tabs_ios:
:path: ".symlinks/plugins/flutter_custom_tabs_ios/ios"
flutter_keychain:
:path: ".symlinks/plugins/flutter_keychain/ios"
flutter_secure_storage:
:path: ".symlinks/plugins/flutter_secure_storage/ios"
fluttertoast:
Expand Down Expand Up @@ -326,7 +321,6 @@ SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_config: f48f0d47a284f1791aacce2687eabb3309ba7a41
flutter_custom_tabs_ios: 62439c843b2691aae516fd50119a01eb9755fff7
flutter_keychain: 01aabf894ffe8b01adfda1d9df21c210c1b4b452
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db
google_maps_flutter_ios: c454f18e0e22df6ac0e9f2a4df340858f5a3680c
Expand Down
23 changes: 23 additions & 0 deletions lib/constants/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,27 @@ class Urls {
static const String clubYoutube =
"https://youtube.com/channel/UCiSzzfW1bVbE_0KcEZO52ew";
static const String clubDiscord = "https://discord.gg/adMkWptn6Y";

// Urls related to MonETS
static const String monEtsAPI = "https://portail.etsmtl.ca/api/";
static const String authenticationMonETS = "${monEtsAPI}authentification";

/// Urls related to SignetsMobile API
/// For more information about the operations supported see:
/// https://signets-ens.etsmtl.ca/Secure/WebServices/SignetsMobile.asmx
static const String signetsAPI =
"https://signets-ens.etsmtl.ca/Secure/WebServices/SignetsMobile.asmx";

// SOAP Operations supported by the Signets API
static const String signetsOperationBase = "http://etsmtl.ca/";
static const String donneesAuthentificationValides =
"donneesAuthentificationValides";
static const String infoStudentOperation = "infoEtudiant";
static const String listProgramsOperation = "listeProgrammes";
static const String listClassScheduleOperation = "lireHoraireDesSeances";
static const String listSessionsOperation = "listeSessions";
static const String listCourseOperation = "listeCours";
static const String listEvaluationsOperation = "listeElementsEvaluation";
static const String listeHoraireEtProf = "listeHoraireEtProf";
static const String readCourseReviewOperation = "lireEvaluationCours";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'package:rive/rive.dart';
import 'package:stacked/stacked.dart';

// Project imports:
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/analytics/analytics_service.dart';
import 'package:notredame/features/app/navigation/navigation_service.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/presentation/rive_animation_service.dart';
import 'package:notredame/utils/locator.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/features/app/error/outage/outage_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import 'package:stacked/stacked.dart';

// Project imports:
import 'package:notredame/constants/urls.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/features/app/error/outage/outage_viewmodel.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:notredame/utils/utils.dart';

class OutageView extends StatelessWidget {
@override
Expand Down
6 changes: 3 additions & 3 deletions lib/features/app/error/outage/outage_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';

// Project imports:
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/navigation/navigation_service.dart';
import 'package:notredame/features/app/analytics/remote_config_service.dart';
import 'package:notredame/utils/locator.dart';
import 'package:notredame/features/app/navigation/navigation_service.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/startup/startup_view.dart';
import 'package:notredame/utils/locator.dart';

class OutageViewModel extends BaseViewModel {
int _lastTap = DateTime.now().millisecondsSinceEpoch;
Expand Down
2 changes: 1 addition & 1 deletion lib/features/app/integration/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';

// Project imports:
import 'package:notredame/features/more/feedback/models/feedback_issue.dart';
import 'package:notredame/features/app/analytics/analytics_service.dart';
import 'package:notredame/features/app/error/internal_info_service.dart';
import 'package:notredame/features/more/feedback/models/feedback_issue.dart';
import 'package:notredame/utils/locator.dart';

class GithubApi {
Expand Down
2 changes: 1 addition & 1 deletion lib/features/app/integration/launch_url_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:url_launcher/url_launcher.dart' as url_launch;

// Project imports:
import 'package:notredame/features/more/settings/settings_manager.dart';
import 'package:notredame/utils/locator.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:notredame/utils/locator.dart';

class LaunchUrlService {
final SettingsManager settingsManager = locator<SettingsManager>();
Expand Down
38 changes: 38 additions & 0 deletions lib/features/app/monets_api/models/mon_ets_user.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// User received from MonETS after a authentication
class MonETSUser {
static const int studentRoleId = 1;
static const String mainDomain = "ENS";

final String domain;

final int typeUsagerId;

/// Username of the user
final String username;

/// Get the universal code extracted from the username
String get universalCode => username.replaceFirst("$domain\\", "");

MonETSUser(
{required this.domain,
required this.typeUsagerId,
required this.username});

MonETSUser.fromJson(Map<String, dynamic> json)
: domain = json['Domaine'] as String,
typeUsagerId = json['TypeUsagerId'] as int,
username = json['Username'] as String;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is MonETSUser &&
runtimeType == other.runtimeType &&
domain == other.domain &&
typeUsagerId == other.typeUsagerId &&
username == other.username;

@override
int get hashCode =>
domain.hashCode ^ typeUsagerId.hashCode ^ username.hashCode;
}
42 changes: 42 additions & 0 deletions lib/features/app/monets_api/monets_api_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Dart imports:
import 'dart:convert';
import 'dart:io';

// Package imports:
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';

// Project imports:
import 'package:notredame/constants/urls.dart';
import 'package:notredame/features/app/monets_api/models/mon_ets_user.dart';
import 'package:notredame/utils/http_exception.dart';

/// A Wrapper for all calls to MonETS API.
class MonETSAPIClient {
static const String tag = "MonETSApi";
static const String tagError = "$tag - Error";

final http.Client _httpClient;

MonETSAPIClient({http.Client? client})
: _httpClient = client ?? IOClient(HttpClient());

/// Authenticate the basic MonETS user
///
/// Throws an [HttpException] if the MonETSApi return anything
/// else than a 200 code
Future<MonETSUser> authenticate(
{required String username, required String password}) async {
final response = await _httpClient.post(
Uri.parse(Urls.authenticationMonETS),
body: {"Username": username, "Password": password});

// Log the http error and throw a exception
if (response.statusCode != 200) {
throw HttpException(
message: response.body, prefix: tagError, code: response.statusCode);
}
return MonETSUser.fromJson(
jsonDecode(response.body) as Map<String, dynamic>);
}
}
8 changes: 4 additions & 4 deletions lib/features/app/navigation/navigation_rail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'package:feature_discovery/feature_discovery.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

// Project imports:
import 'package:notredame/features/welcome/discovery/models/discovery_ids.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/analytics/analytics_service.dart';
import 'package:notredame/features/app/navigation/navigation_service.dart';
import 'package:notredame/utils/locator.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/welcome/discovery/discovery_components.dart';
import 'package:notredame/features/welcome/discovery/models/discovery_ids.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:notredame/utils/locator.dart';

/// Bottom navigation bar for the application.
class NavRail extends StatefulWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/features/app/navigation/navigation_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import 'package:flutter/material.dart';

// Project imports:
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/analytics/analytics_service.dart';
import 'package:notredame/features/app/analytics/remote_config_service.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/utils/locator.dart';

//SERVICE
Expand Down
31 changes: 15 additions & 16 deletions lib/features/app/navigation/router.dart
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
// Flutter imports:
import 'package:flutter/material.dart';

// Package imports:
import 'package:ets_api_clients/models.dart';

// Project imports:
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/constants/update_code.dart';
import 'package:notredame/features/ets/events/author/author_view.dart';
import 'package:notredame/features/app/error/not_found/not_found_view.dart';
import 'package:notredame/features/app/error/outage/outage_view.dart';
import 'package:notredame/features/app/navigation/router_paths.dart';
import 'package:notredame/features/app/signets-api/models/course.dart';
import 'package:notredame/features/app/startup/startup_view.dart';
import 'package:notredame/features/app/widgets/link_web_view.dart';
import 'package:notredame/features/dashboard/dashboard_view.dart';
import 'package:notredame/features/ets/ets_view.dart';
import 'package:notredame/features/ets/events/api-client/models/news.dart';
import 'package:notredame/features/ets/events/author/author_view.dart';
import 'package:notredame/features/ets/events/news/news-details/news_details_view.dart';
import 'package:notredame/features/ets/events/news/news_view.dart';
import 'package:notredame/features/ets/quick-link/models/quick_link.dart';
import 'package:notredame/features/ets/quick-link/quick_links_view.dart';
import 'package:notredame/features/ets/quick-link/widgets/security-info/security_view.dart';
import 'package:notredame/features/more/about/about_view.dart';
import 'package:notredame/features/more/settings/choose_language_view.dart';
import 'package:notredame/features/more/contributors/contributors_view.dart';
import 'package:notredame/features/dashboard/dashboard_view.dart';
import 'package:notredame/features/more/faq/faq_view.dart';
import 'package:notredame/features/more/feedback/feedback_view.dart';
import 'package:notredame/features/student/grades/grade_details/grade_details_view.dart';
import 'package:notredame/features/welcome/login/login_view.dart';
import 'package:notredame/features/more/more_view.dart';
import 'package:notredame/features/app/error/not_found/not_found_view.dart';
import 'package:notredame/features/app/error/outage/outage_view.dart';
import 'package:notredame/features/ets/quick-link/quick_links_view.dart';
import 'package:notredame/features/more/settings/choose_language_view.dart';
import 'package:notredame/features/more/settings/settings_view.dart';
import 'package:notredame/features/schedule/schedule_default/schedule_default_view.dart';
import 'package:notredame/features/schedule/schedule_view.dart';
import 'package:notredame/features/ets/quick-link/widgets/security-info/security_view.dart';
import 'package:notredame/features/more/settings/settings_view.dart';
import 'package:notredame/features/app/startup/startup_view.dart';
import 'package:notredame/features/student/grades/grade_details/grade_details_view.dart';
import 'package:notredame/features/student/student_view.dart';
import 'package:notredame/features/app/widgets/link_web_view.dart';
import 'package:notredame/features/welcome/login/login_view.dart';

Route<dynamic> generateRoute(RouteSettings routeSettings) {
switch (routeSettings.name) {
Expand Down
8 changes: 2 additions & 6 deletions lib/features/app/repository/author_repository.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Flutter imports:
import 'package:ets_api_clients/clients.dart';

// Package imports:
import 'package:ets_api_clients/models.dart';

// Project imports:
import 'package:notredame/features/ets/events/api-client/hello_api_client.dart';
import 'package:notredame/features/ets/events/api-client/models/organizer.dart';
import 'package:notredame/utils/locator.dart';

/// Repository to access authors
Expand Down
16 changes: 11 additions & 5 deletions lib/features/app/repository/course_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ import 'dart:convert';
import 'package:flutter/material.dart';

// Package imports:
import 'package:ets_api_clients/clients.dart';
import 'package:ets_api_clients/exceptions.dart';
import 'package:ets_api_clients/models.dart';
import 'package:logger/logger.dart';

// Project imports:
import 'package:notredame/features/app/storage/cache_manager.dart';
import 'package:notredame/features/app/repository/user_repository.dart';
import 'package:notredame/features/app/analytics/analytics_service.dart';
import 'package:notredame/features/app/integration/networking_service.dart';
import 'package:notredame/features/app/repository/user_repository.dart';
import 'package:notredame/features/app/signets-api/models/course.dart';
import 'package:notredame/features/app/signets-api/models/course_activity.dart';
import 'package:notredame/features/app/signets-api/models/course_review.dart';
import 'package:notredame/features/app/signets-api/models/course_summary.dart';
import 'package:notredame/features/app/signets-api/models/schedule_activity.dart';
import 'package:notredame/features/app/signets-api/models/session.dart';
import 'package:notredame/features/app/signets-api/models/signets_errors.dart';
import 'package:notredame/features/app/signets-api/signets_api_client.dart';
import 'package:notredame/features/app/storage/cache_manager.dart';
import 'package:notredame/features/student/semester_codes.dart';
import 'package:notredame/utils/api_exception.dart';
import 'package:notredame/utils/cache_exception.dart';
import 'package:notredame/utils/locator.dart';

Expand Down
8 changes: 2 additions & 6 deletions lib/features/app/repository/news_repository.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Flutter imports:
import 'package:ets_api_clients/clients.dart';

// Package imports:
import 'package:ets_api_clients/models.dart';

// Project imports:
import 'package:notredame/features/app/storage/cache_manager.dart';
import 'package:notredame/features/ets/events/api-client/hello_api_client.dart';
import 'package:notredame/features/ets/events/api-client/models/paginated_news.dart';
import 'package:notredame/utils/locator.dart';

/// Repository to access all the news
Expand Down
2 changes: 1 addition & 1 deletion lib/features/app/repository/quick_link_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'dart:convert';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

// Project imports:
import 'package:notredame/features/ets/quick-link/models/quick_links.dart';
import 'package:notredame/features/app/storage/cache_manager.dart';
import 'package:notredame/features/ets/quick-link/models/quick_link.dart';
import 'package:notredame/features/ets/quick-link/models/quick_link_data.dart';
import 'package:notredame/features/ets/quick-link/models/quick_links.dart';
import 'package:notredame/utils/locator.dart';

class QuickLinkRepository {
Expand Down
12 changes: 8 additions & 4 deletions lib/features/app/repository/user_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

// Package imports:
import 'package:ets_api_clients/clients.dart';
import 'package:ets_api_clients/exceptions.dart';
import 'package:ets_api_clients/models.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:logger/logger.dart';

// Project imports:
import 'package:notredame/features/app/storage/cache_manager.dart';
import 'package:notredame/features/app/analytics/analytics_service.dart';
import 'package:notredame/features/app/integration/networking_service.dart';
import 'package:notredame/features/app/monets_api/models/mon_ets_user.dart';
import 'package:notredame/features/app/monets_api/monets_api_client.dart';
import 'package:notredame/features/app/signets-api/models/profile_student.dart';
import 'package:notredame/features/app/signets-api/models/program.dart';
import 'package:notredame/features/app/signets-api/signets_api_client.dart';
import 'package:notredame/features/app/storage/cache_manager.dart';
import 'package:notredame/utils/api_exception.dart';
import 'package:notredame/utils/cache_exception.dart';
import 'package:notredame/utils/http_exception.dart';
import 'package:notredame/utils/locator.dart';

class UserRepository {
Expand Down
Loading