ASWImplementation constructor

ASWImplementation({
  1. required Dio dio,
  2. List<Interceptor>? interceptors,
  3. Future<Either<String, ASWTokenPair>> tokenRefreshCallback(
    1. String refreshToken
    )?,
  4. VoidCallback? onTokenExpired,
})

Implementation

ASWImplementation({
  required this.dio,
  this.interceptors,
  this.tokenRefreshCallback,
  this.onTokenExpired,
}) : _tokenManager = ASWTokenManager.instance {
  final allInterceptors = [...?interceptors];

  if (!allInterceptors.any(
    (interceptor) => interceptor is ASWTokenInterceptor,
  )) {
    allInterceptors.add(
      ASWTokenInterceptor(
        tokenManager: _tokenManager,
        tokenRefreshCallback: tokenRefreshCallback,
        onTokenExpired: onTokenExpired,
      ),
    );
  }

  dio.interceptors.addAll(allInterceptors);
}