import 'package:dio/dio.dart' hide Headers;
import 'package:eitc_erm_dental_flutter/entity/clinic_info.dart';
import 'package:eitc_erm_dental_flutter/entity/dict_info.dart';
import 'package:eitc_erm_dental_flutter/entity/login_info.dart';
import 'package:eitc_erm_dental_flutter/entity/patient_info.dart';
import 'package:eitc_erm_dental_flutter/entity/version_info.dart';
import 'package:eitc_erm_dental_flutter/http/api_response.dart';
import 'package:retrofit/retrofit.dart';

part 'api_service.g.dart';

@RestApi()
abstract class ApiService {
  factory ApiService(Dio dio, {String? baseUrl}) = _ApiService;

  ///登录
  ///
  /// [phoneNumber] 手机号
  @POST("/app/login")
  @Headers(<String, dynamic>{
    'Content-Type': 'application/json',
  })
  Future<ApiResponse<LoginInfo>> login(
      @Field("phoneNumber") String phoneNumber);

  ///登出
  @GET("/app/logout")
  Future<ApiResponse<dynamic>> logout(@Header("token") String token);

  ///发送验证码
  ///
  ///[phoneNumber] 手机号
  @POST("/app/sendCaptchaCode")
  @Headers(<String, dynamic>{
    'Content-Type': 'application/json',
  })
  Future<ApiResponse<dynamic>> sendCaptchaCode(
      @Field("phoneNumber") String phoneNumber);

  ///检查验证码
  ///
  /// [captchaCode] 验证码
  ///
  /// [phoneNumber] 手机号
  @POST("/app/checkCaptchaCode")
  @Headers(<String, dynamic>{
    'Content-Type': 'application/json',
  })
  Future<ApiResponse<dynamic>> checkCaptchaCode(
      @Field("captchaCode") String captchaCode,
      @Field("phoneNumber") String phoneNumber);

  ///获取字典列表
  ///
  /// [dictType] 字典类型,关系:erm_personal_relationship
  @GET("/app/api/type/{dictType}")
  Future<ApiResponse<List<DictInfo>>> dictList(
      @Path("dictType") String dictType);

  ///获取版本信息
  ///
  /// [type] 类型,android,ios
  @GET("/app/api/findVersion")
  Future<ApiResponse<VersionInfo>> getVersion(@Query("type") String type);

  ///获取咨询人列表
  @GET("/app/user/list")
  Future<ApiResponse<List<PatientInfo>>> getPatientList();

  ///获取诊所列表
  @GET("/app/api/clinicList")
  Future<ApiResponse<List<ClinicInfo>>> getClinicList();

  ///添加咨询人
  ///
  /// [name]  名字
  /// [idCard]  身份证号
  /// [relation]  关系
  @POST("/app/user")
  @Headers(<String, dynamic>{
    'Content-Type': 'application/json',
  })
  Future<ApiResponse<dynamic>> addPatient(
      @Field("patientName") String name,
      @Field("identificationCard") String idCard,
      @Field("relationship") String relation);

  ///隐私政策
  @GET("/app/api/privacyPolicy")
  Future<HttpResponse<String>> getPrivacyPolicy();

  ///用户协议
  @GET("/app/api/userAgreement")
  @ResponseType.bytes
  Future<HttpResponse<String>> getUserAgreement();

  ///权限说明
  ///
  /// [type] 类型,android,ios
  @GET("/app/api/permissionDescription")
  @ResponseType.bytes
  Future<HttpResponse<String>> getPermissionDescription(
      @Query("type") String type);
}
