retryLatestFailedApiCall static method
Retries the latest failed API call using current auth context.
This is useful after host app refreshes login/token.
Implementation
static Future<Response?> retryLatestFailedApiCall() async {
// Legacy retry is suppressed while the shared auth refresh gate is active.
// This prevents conflicts with the new host-driven `updateAuthToken(...)` flow.
if (_authRefreshCompleter != null) return null;
if (_failed401ApiCalls.isEmpty) return null;
final _RetryableApiCall latest = _failed401ApiCalls.last;
late Response response;
if (latest.requestType == RequestType.get) {
response = await _dio.get(
latest.url,
queryParameters: latest.queryParameters,
options: Options(headers: latest.headers),
);
} else if (latest.requestType == RequestType.post) {
response = await _dio.post(
latest.url,
data: latest.data,
queryParameters: latest.queryParameters,
options: Options(headers: latest.headers),
);
} else if (latest.requestType == RequestType.put) {
response = await _dio.put(
latest.url,
data: latest.data,
queryParameters: latest.queryParameters,
options: Options(headers: latest.headers),
);
} else if (latest.requestType == RequestType.patch) {
response = await _dio.patch(
latest.url,
data: latest.data,
queryParameters: latest.queryParameters,
options: Options(headers: latest.headers),
);
} else {
response = await _dio.delete(
latest.url,
data: latest.data,
queryParameters: latest.queryParameters,
options: Options(headers: latest.headers),
);
}
_untrack401FailedCall(latest);
return response;
}