This commit is contained in:
2026-10-21 08:54:03 +02:00
parent 4f375e6766
commit 1ce33a69d1
11 changed files with 24 additions and 17 deletions

View File

@@ -139,8 +139,7 @@ class IntraAuthService {
_refreshToken = refresh;
}
/// Simule un access token expiré (garde le refresh) — tests bonus en debug.
@visibleForTesting
/// Simule un access token expiré (garde le refresh) — démo bonus, appelé depuis l’UI en `kDebugMode`.
void debugInvalidateAccessToken() {
if (!canRefresh) return;
_accessToken = 'invalid_access_token_for_refresh_test';

View File

@@ -50,6 +50,7 @@ Duration _retryDelay(http.Response response, int attempt) {
return Duration(milliseconds: ms.clamp(800, 8000));
}
/// Lance une [IntraApiException] si le code HTTP n'est pas 200.
void ensureIntraOk(http.Response response) {
if (response.statusCode == 401) {
throw const IntraUnauthorizedException();
@@ -67,6 +68,7 @@ void ensureIntraOk(http.Response response) {
}
}
/// Décode le corps JSON après contrôle du statut HTTP.
dynamic decodeIntraBody(http.Response response) {
ensureIntraOk(response);
return jsonDecode(response.body);

View File

@@ -55,10 +55,12 @@ class _ProfileCacheEntry {
final DateTime fetchedAt;
}
/// Agrège fiche user, skills (cursus, pas `/experiences`) et `projects_users` (scope `projects`).
class IntraProfileService {
IntraProfileService._();
static final IntraProfileService instance = IntraProfileService._();
/// Cache court + délai entre GET pour limiter les 429 sur l'API 42.
static const Duration _cacheTtl = Duration(minutes: 2);
static const Duration _betweenRequests = Duration(milliseconds: 450);

View File

@@ -8,6 +8,7 @@ import 'intra_api_exception.dart';
import 'intra_auth_service.dart';
import 'intra_http.dart';
/// Recherche d'un login via `GET /v2/users?filter[login]=` (même token OAuth que le profil).
class IntraUserService {
IntraUserService._();
static final IntraUserService instance = IntraUserService._();