-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into need-help-page-improvements
# Conflicts: # lib/features/more/faq/faq_view.dart # test/ui/views/goldenFiles/newsDetailsView_1.png
- Loading branch information
Showing
181 changed files
with
4,862 additions
and
436 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
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
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
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
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
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
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
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,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; | ||
} |
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,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>); | ||
} | ||
} |
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
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
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
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
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
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
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
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
Oops, something went wrong.