initialize function

Future<void> initialize({
  1. String? apiKey,
  2. String? environment,
  3. bool autoInitWithAdmin = true,
  4. bool debug = false,
  5. bool enableLogging = false,
  6. int timeout = 30000,
  7. int retryAttempts = 3,
})

Alternative initialization function for backward compatibility Supports the old initialization pattern

Implementation

Future<void> initialize({
  String? apiKey,
  String? environment,
  bool autoInitWithAdmin = true,
  bool debug = false,
  bool enableLogging = false,
  int timeout = 30000,
  int retryAttempts = 3,
}) async {
  try {
    OnairosDebugHelper.log('🔑 Initializing Onairos SDK (backward compatibility mode)');

    // Create configuration
    final config = OnairosConfig(
      apiKey: apiKey,
      environment: environment,
      autoInitWithAdmin: autoInitWithAdmin,
      debug: debug,
      enableLogging: enableLogging,
      timeout: timeout,
      retryAttempts: retryAttempts,
    );

    // Initialize the SDK
    final onairosService = OnairosService();
    await onairosService.initializeApiKey(config);

    OnairosDebugHelper.log('✅ Onairos SDK initialized successfully!');

  } catch (e) {
    OnairosDebugHelper.log('❌ SDK initialization failed: $e');
    rethrow;
  }
}