// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'rest_client.dart';

// **************************************************************************
// RetrofitGenerator
// **************************************************************************

class _RestClient implements RestClient {
  _RestClient(this._dio, {this.baseUrl}) {
    ArgumentError.checkNotNull(_dio, '_dio');
    baseUrl ??= 'https://tpf.aztrace.vn/';
  }

  final Dio _dio;

  String? baseUrl;

  @override
  login(userRequest) async {
    ArgumentError.checkNotNull(userRequest, 'userRequest');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(userRequest?.toJson() ?? <String, dynamic>{});
    final Response<Map<String, dynamic>> _result = await _dio.request('/api/authenticate', queryParameters: queryParameters, data: _data);
    final value = User.fromJson(_result.data!);
    return value;
  }

  @override
  getMe() async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    final Response<Map<String, dynamic>> _result = await _dio.request('/api/account', queryParameters: queryParameters, data: _data);
    final value = Account.fromJson(_result.data ?? Map<String, dynamic>());
    return value;
  }

  @override
  forgotPassword(email) async {
    ArgumentError.checkNotNull(email, 'email');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = email;
    await _dio.request<void>(
      '/api/account/reset-password/init',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  resetPassword(password) async {
    ArgumentError.checkNotNull(password, 'password');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(password.toJson() ?? <String, dynamic>{});
    await _dio.request<void>('/api/account/reset-password/finish', queryParameters: queryParameters, data: _data);
    return null;
  }

  @override
  changePassword(password) async {
    ArgumentError.checkNotNull(password, 'password');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(password?.toJson() ?? <String, dynamic>{});
    await _dio.request<void>(
      '/api/account/change-password',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  updateProfile(account) async {
    ArgumentError.checkNotNull(account, 'account');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(account?.toJson() ?? <String, dynamic>{});
    final Response<Map<String, dynamic>> _result = await _dio.request('/api/update-my-profile', queryParameters: queryParameters, data: _data);
    final value = Account.fromJson(_result.data ?? Map<String, dynamic>());
    return value;
  }

  @override
  getSupplies(type, {Options? options, query = ""}) async {
    ArgumentError.checkNotNull(type, 'type');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/list-supplies-in-warehouses/$type?q=$query',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => Supply.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  updateFcmToken(token) async {
    ArgumentError.checkNotNull(token, 'token');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = token;
    await _dio.request<void>(
      '/api/update-fcmToken',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  deleteFcmToken(token) async {
    ArgumentError.checkNotNull(token, 'token');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = token;
    await _dio.request<void>(
      '/api/delete-fcmToken',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  getPlots({page = 0, size = 20, query = ""}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/_search/tb-crops?page=$page&size=$size&sort=id,asc&query=$query',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => Crop.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getActionTypes({Options? options}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/listActivityTypesOther',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => ActionType.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getWaterTypes({Options? options}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/water-types',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => WaterType.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getHarvests({Options? options}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/tb-harvests',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => Harvest.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getDeviceForActivity({Options? options}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/listDeviceForActivity',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => Device.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  updateAllNotification(status) async {
    ArgumentError.checkNotNull(status, 'status');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = status;
    await _dio.request<void>(
      '/api/notifications/update-all',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  updateNoti(updateNoti) async {
    ArgumentError.checkNotNull(updateNoti, 'updateNoti');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(updateNoti?.toJson() ?? <String, dynamic>{});
    await _dio.request<void>(
      '/api/notifications/update',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  getCountries({page = 0, size = 400, query = '', Options? options}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/tb-countries?page=$page&size=$size&query=$query&&sort=name,ASC',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => LocationUnit.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getProvinces(countryId, {page = 0, size = 20, query = '', Options? options}) async {
    ArgumentError.checkNotNull(countryId, 'countryId');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/tb-cities-by-country/$countryId?page=$page&size=$size&query=$query&&sort=name,ASC',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => LocationUnit.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getDistricts(provinceId, {page = 0, size = 20, query = '', Options? options}) async {
    ArgumentError.checkNotNull(provinceId, 'provinceId');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/tb-districts-by-city/$provinceId?page=$page&size=$size&query=$query&&sort=name,ASC',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => LocationUnit.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getWards(districtId, {page = 0, size = 20, query = '', Options? options}) async {
    ArgumentError.checkNotNull(districtId, 'districtId');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final newOptions = newRequestOptions(options ?? Options());
    newOptions.extra.addAll(_extra);
    newOptions.headers.addAll(<String, dynamic>{});
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/tb-wards-by-district/$districtId?page=$page&size=$size&query=$query&&sort=name,ASC',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => LocationUnit.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getCropDetail(cropId, {page = 0, size = 20}) async {
    ArgumentError.checkNotNull(cropId, 'cropId');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final Response<Map<String, dynamic>> _result = await _dio.request(
      '/api/tb-crops-detail-for-app/$cropId?page=$page&size=$size&sort=executeDate,DESC',
      queryParameters: queryParameters,
      data: _data,
    );
    final value = CropPlot.fromJson(_result.data ?? Map<String, dynamic>());
    return value;
  }

  @override
  getCropDetailByCode(cropCode, {page = 0, size = 20}) async {
    ArgumentError.checkNotNull(cropCode, 'cropCode');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final Response<Map<String, dynamic>> _result = await _dio.request(
      '/api/tb-crops-scan-qrCode/$cropCode?page=$page&size=$size&sort=executeDate,DESC',
      queryParameters: queryParameters,
      data: _data,
    );
    final value = CropPlot.fromJson(_result.data ?? Map<String, dynamic>());
    return value;
  }

  @override
  updateCrop(crop) async {
    ArgumentError.checkNotNull(crop, 'crop');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    _data.addAll(crop?.toJson() ?? <String, dynamic>{});
    await _dio.request<void>(
      '/api/tb-crops',
      queryParameters: queryParameters,
      data: _data,
    );
    return null;
  }

  @override
  getDevices({String? query}) async {
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    final _data = <String, dynamic>{};
    final Response<List<dynamic>> _result =
        await _dio.request('/api/listDeviceOfUserCustomers?query=$query', queryParameters: queryParameters, data: _data);
    var value = _result.data?.map((dynamic i) => Device.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  @override
  getEnvironmentParameters(cropId, {page = 0, size = 20}) async {
    ArgumentError.checkNotNull(cropId, 'cropId');
    const _extra = <String, dynamic>{};
    final queryParameters = <String, dynamic>{};
    queryParameters.removeWhere((k, v) => v == null);
    final _data = <String, dynamic>{};
    final Response<List<dynamic>> _result = await _dio.request(
      '/api/list-environment-updates-display/$cropId?page=$page&size=$size',
      queryParameters: queryParameters,
      data: _data,
    );
    var value = _result.data?.map((dynamic i) => EnvironmentParameter.fromJson(i as Map<String, dynamic>)).toList();
    return value ?? [];
  }

  RequestOptions newRequestOptions(Options? options) {
    // if (options is RequestOptions) {
    //   // return options ?? RequestOptions(path: '');
    //   return RequestOptions!;
    // }
    if (options == null) {
      return RequestOptions(path: '');
    }
    return RequestOptions(
      method: options.method,
      sendTimeout: options.sendTimeout,
      receiveTimeout: options.receiveTimeout,
      extra: options.extra,
      headers: options.headers,
      responseType: options.responseType,
      contentType: options.contentType.toString(),
      validateStatus: options.validateStatus,
      receiveDataWhenStatusError: options.receiveDataWhenStatusError,
      followRedirects: options.followRedirects,
      maxRedirects: options.maxRedirects,
      requestEncoder: options.requestEncoder,
      responseDecoder: options.responseDecoder,
      path: '',
    );
  }
}
