/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2022-01-19 16:44:35
 * @LastEditTime : 2023-11-06 15:30:17
 * @Description  : Do not edit
 */
import 'package:app_package/app_package.dart';

import '../models/detail_model.dart';
import '../models/record_model.dart';

class MeterService {
  static Future<ResModel<DetailModel>> getMeterDetail(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/hgj/meter/detail',
      queryParameters: data,
    );

    return ResModel<DetailModel>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => DetailModel.fromJson(v),
    );
  }

  static Future<ResModel<num>> postCancelMeterRead(data) async {
    var res = await HttpUtil.instance.post(
      '/app/admin/hgj/meter/amount/recall',
      data: data,
    );

    return ResModel<num>(
      json: res.data,
      to: (v) => v,
      from: (v) => v,
    );
  }

  static Future<ResModel<PagingModel<RecordModel>>>
      getCommonMeterReadingHisrory(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/meterReading/common/record',
      queryParameters: data,
    );

    return ResModel<PagingModel<RecordModel>>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => PagingModel(
        json: v,
        to: (v) => v.toJson(),
        from: (v) => RecordModel.fromJson(v),
      ),
    );
  }

  static Future<ResModel<PagingModel<RecordModel>>>
      getResidentMeterReadingHisrory(data) async {
    var res = await HttpUtil.instance.get(
      '/app/admin/meterReading/record',
      queryParameters: data,
    );

    return ResModel<PagingModel<RecordModel>>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => PagingModel(
        json: v,
        to: (v) => v.toJson(),
        from: (v) => RecordModel.fromJson(v),
      ),
    );
  }
}
