getConfig method

Future<SdkConfig> getConfig(
  1. String token
)

Implementation

Future<SdkConfig> getConfig(String token) async {
  try {
    if (configTs != null && isTodayTs(configTs!)) {
      return sdkConfig;
    }
    final config = await _getConfigFromCache();
    configTs = await _getConfigTsFromCache();
    if (config != null && configTs != null && isTodayTs(configTs!)) {
      Debug.print("ConfigManager: Config found in cache. $config");
      return sdkConfig = config;
    }
    return _fetchConfigAndStoreInCache(token);
  } catch (e) {
    Debug.print("ConfigManager: Fetching config failed. Error: $e");
    return SdkConfig.defaultConfig;
  }
}