import 'app_usage_api.dart';
import 'seos_mobile_keys_plugin_platform_interface.dart';

class SeosMobileKeysPlugin {
  Future<void> startUp(Map<String?, Object?> options) =>
      _platformInstance.startUp(options);

  Future<bool> deviceHasBluetoothTurnedOn() =>
      _platformInstance.deviceHasBluetoothTurnedOn();

  Future<bool> deviceSupportsBluetoothLowEnergy() =>
      _platformInstance.deviceSupportsBluetoothLowEnergy();

  Future<bool> isEndpointSetup() =>
      _platformInstance.isEndpointSetup();

  Future<void> setupEndpoint(String invitationCode) =>
      _platformInstance.setupEndpoint(invitationCode);

  Future<void> updateEndpoint() =>
      _platformInstance.updateEndpoint();

  Future<void> terminateEndpoint() =>
      _platformInstance.terminateEndpoint();

  Future<List<MobileKeysKey>> listMobileKeys() =>
      _platformInstance.listMobileKeys();

  Future<bool> activateMobileKey(MobileKeysKey key) =>
      _platformInstance.activateMobileKey(key);

  Future<bool> deactivateMobileKey(MobileKeysKey key) =>
      _platformInstance.deactivateMobileKey(key);

  Future<String> generateOTPForKey(MobileKeysKey key) =>
      _platformInstance.generateOTPForKey(key);

  Future<int> otpCounterForKey(MobileKeysKey key) =>
      _platformInstance.otpCounterForKey(key);

  Future<MobileKeysEndpointInfo> endpointInfo() =>
      _platformInstance.endpointInfo();

  Future<List<MobileKeysInfoType>> healthCheck() =>
      _platformInstance.healthCheck();

  Future<String> apiVersion() =>
      _platformInstance.apiVersion();

  Future<bool> isScanning() =>
      _platformInstance.isScanning();

  Future<void> startReaderScan(
      MobileKeysScanMode mode,
      List<MobileKeysOpeningType?> supportedOpeningTypes,
      List<int?> lockServiceCodes) =>
      _platformInstance.startReaderScan(
          mode,
          supportedOpeningTypes,
          lockServiceCodes);

  Future<void> setSupportedOpeningTypes(List<MobileKeysOpeningType> supportedOpeningTypes) =>
      _platformInstance.setSupportedOpeningTypes(supportedOpeningTypes);

  Future<void> setTimeoutConfiguration(MobileKeysTimeoutConfiguration timeoutConfiguration) =>
      _platformInstance.setTimeoutConfiguration(timeoutConfiguration);

  Future<void> stopReaderScan() =>
      _platformInstance.stopReaderScan();

  Future<MobileKeysLastAuthenticationInfo> lastAuthenticationInfo() =>
      _platformInstance.lastAuthenticationInfo();

  Future<List<MobileKeysReader>> listReaders() =>
      _platformInstance.listReaders();

  Future<MobileKeysReader?> closestReaderWithinRangeOfOpeningType(MobileKeysOpeningType type) =>
      _platformInstance.closestReaderWithinRangeOfOpeningType(type);

  Future<void> connectToReader(MobileKeysReader reader, MobileKeysOpeningType openingType) =>
      _platformInstance.connectToReader(reader, openingType);

  Future<void> forceConnectToReader(MobileKeysReader reader, MobileKeysOpeningType openingType) =>
      _platformInstance.forceConnectToReader(reader, openingType);

  Future<void> cancelReaderConnection(MobileKeysReader reader) =>
      _platformInstance.cancelReaderConnection(reader);

  Future<void> openClosestReader() =>
      _platformInstance.openClosestReader();

  Future<void> removeRootOpeningTrigger() =>
      _platformInstance.removeRootOpeningTrigger();

  Future<void> setRootOpeningTrigger() =>
      _platformInstance.setRootOpeningTrigger();

  Future<bool> isAnalyticsEnabled() =>
      _platformInstance.isAnalyticsEnabled();

  Future<void> analytics(bool enable) =>
      _platformInstance.analytics(enable);

  stopIfScanning() async {
    if (await isScanning()) await stopReaderScan();
  }
  
  SeosMobileKeysPluginPlatform get _platformInstance =>
      SeosMobileKeysPluginPlatform.instance;
}