import 'package:dio/dio.dart';
import 'api_client.dart';
import 'mock_api_client.dart';

abstract class IApiClient {
  Future<Response<T>> get<T>(String path, {Options? options});
  Future<Response<T>> post<T>(String path, {dynamic data, Options? options});
  Future<Response<T>> patch<T>(String path, {dynamic data, Options? options});
  Future<Response<T>> delete<T>(String path, {dynamic data, Options? options});
}

class ApiClientWrapper implements IApiClient {
  final ApiClient _client;

  ApiClientWrapper(this._client);

  @override
  Future<Response<T>> get<T>(String path, {Options? options}) =>
      _client.get(path, options: options);

  @override
  Future<Response<T>> post<T>(String path, {dynamic data, Options? options}) =>
      _client.post(path, data: data, options: options);

  @override
  Future<Response<T>> patch<T>(String path, {dynamic data, Options? options}) =>
      _client.patch(path, data: data, options: options);

  @override
  Future<Response<T>> delete<T>(
    String path, {
    dynamic data,
    Options? options,
  }) => _client.delete(path, data: data, options: options);
}

class MockApiClientWrapper implements IApiClient {
  final MockApiClient _client;

  MockApiClientWrapper(this._client);

  @override
  Future<Response<T>> get<T>(String path, {Options? options}) =>
      _client.get(path, options: options);

  @override
  Future<Response<T>> post<T>(String path, {dynamic data, Options? options}) =>
      _client.post(path, data: data, options: options);

  @override
  Future<Response<T>> patch<T>(String path, {dynamic data, Options? options}) =>
      _client.patch(path, data: data, options: options);

  @override
  Future<Response<T>> delete<T>(
    String path, {
    dynamic data,
    Options? options,
  }) => _client.delete(path, data: data, options: options);
}
