
import 'dart:io';

import 'package:app_package/src/models/app_update.dart';
import 'package:app_package/src/models/res.dart';
import 'package:device_info_plus/device_info_plus.dart';

import '../utils/http.dart';
class UpdateApi {
  static String _prefix = '/app/admin';

  ///app更新
  ///http://yapi.wisdomcity.com.cn/project/40/interface/api/7697
  static Future<ResModel<AppUpdateModel>> getUpdateInfo(data) async {
    String systemVesion;
    String phoneModel;

    if (Platform.isAndroid) {
      final androidInfo = await DeviceInfoPlugin().androidInfo;
      systemVesion = androidInfo.version.release;
      phoneModel = androidInfo.model;
    } else {
      final iosInfo = await DeviceInfoPlugin().iosInfo;
      systemVesion = iosInfo.systemVersion;
      phoneModel = iosInfo.model;
    }
    var res = await HttpUtil.instance.get(
      '$_prefix/vesion/hgj/v1/check/update',
      queryParameters: {
        ...data,
        'systemVesion': systemVesion,
        'phoneModel': phoneModel,
      },
    );

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