init method

  1. @override
Future<IRestApiClient> init()
override

Method that initializes RestApiClient instance

Implementation

@override
Future<IRestApiClient> init() async {
  await _storageRepository.init();
  if (loggingOptions.logStorage) {
    await _storageRepository.log();
  }

  await _cachedStorageRepository.init();
  if (loggingOptions.logCacheStorage) {
    await _cachedStorageRepository.log();
  }

  final jwt = await _storageRepository.get(RestApiClientKeys.jwt);
  if (jwt != null && jwt is String && jwt.isNotEmpty) {
    _addOrUpdateHeader(
        key: RestApiClientKeys.authorization, value: 'Bearer $jwt');
  }

  return this;
}