import '../../../networks_sdk.dart';
import 'networks_sdk_core.dart';

/// [NetworksSdkApi] 的实现，透传给 Repository
class NetworksSdkApiImpl implements NetworksSdkApi {
  final NetworksSdkCore _core;

  NetworksSdkApiImpl({required NetworksSdkCore core}) : _core = core;

  @override
  Future<String?> platformVersion() => _core.repo.platformVersion();

  @override
  void initialize(ApiConfig apiConfig) => _core.repo.initialize(apiConfig);

  @override
  Future<T?> executeRequest<T>(
    ApiRequestable<T> request, {
    CancelToken? cancelToken,
  }) {
    return _core.repo.executeRequest(request, cancelToken: cancelToken);
  }

  @override
  Future<void> executeDownload({
    required String url,
    required String savePath,
    OnDownloadProgress? onProgress,
    CancelToken? cancelToken,
    bool resume = false,
    Map<String, String>? headers,
  }) {
    return _core.repo.executeDownload(
      url: url,
      savePath: savePath,
      onProgress: onProgress,
      cancelToken: cancelToken,
      resume: resume,
      headers: headers,
    );
  }
}
