import 'dart:io';

import 'package:dio/dio.dart' hide Headers;
import 'package:retrofit/retrofit.dart';
import 'package:sport/bean/achievement_detail_info.dart';
import 'package:sport/bean/achievement_info.dart';
import 'package:sport/bean/bind_info.dart';
import 'package:sport/bean/feed_back.dart';
import 'package:sport/bean/game.dart';
import 'package:sport/bean/login.dart';
import 'package:sport/bean/rank_info.dart';
import 'package:sport/services/api/resp.dart';

part 'login_api.g.dart';

//@RestApi(baseUrl: "https://local.moodrain.cn")
@RestApi()
abstract class LoginApi {
  factory LoginApi(Dio dio, {String baseUrl}) = _LoginApi;

  @POST("/user/loginByPhone")
  Future<LoginInfo> getLoginInfo(@Query("phone") String phone, {@Query("password") String password, @Query("captcha") String captcha});

  @POST("/user/sendCaptcha")
  Future getCaptcha(@Query("phone") String phone);

  @POST("/user/loginByQQ")
  Future loginQQ(@Query("openid") String openid, @Query("name") String name,
      {@Query("unionid") String unionid, @Query("avatar") String avatar, @Query("gender") int gender});

  @POST("/user/loginByWx")
  Future loginByWx(@Query("code") String code);

  @POST("/user/registerByPhone")
  Future registerByPhone(@Query("phone") String phone, @Query("password") String password, @Query("captcha") String captcha);

  @POST("/user/updateInfo")
  Future updateInfo(
    @Query("name") String name,
    @Query("gender") int gender, {
    @Query("age") int age,
    @Query("province_id") int province_id,
    @Query("city_id") int city_id,
    @Query("district_id") int district_id,
  });

  @POST("/user/verifyCaptcha")
  Future verifyCaptcha(
    @Query("phone") String phone,
    @Query("captcha") String captcha,
  );

  @POST("/user/resetPasswordByCaptcha")
  Future resetPasswordByCaptcha(
    @Query("phone") String phone,
    @Query("captcha") String captcha,
    @Query("password") String password,
  );

  @GET("/achievement/info")
  Future<AchievementInfo> getAchievementInfo();

  @GET('/achievement/show')
  Future<AchieveDetailInfo> getAchieveDetailInfo(@Query("id") int id, {@Query("user_id") String userId});

  @GET('/user/bindInfo')
  Future<BindInfo> getBindInfo();

  @GET('/user/bindPhone')
  Future bindPhone(@Query("phone") String phone, @Query("captcha") String captcha);

  @GET('/user/bindWx')
  Future bindWx(@Query("code") String code);

  @GET("/user/bindQQ")
  Future bindQQ(@Query("openid") String openid, {@Query("unionid") String unionid});

  @POST("/user/resetPasswordByOld")
  Future resetPasswordByOld(@Query("old_password") String old_password, @Query("new_password") String new_password);

  @GET("/feedback/types")
  Future<FeedTypeInfo> getFeedBackTypes();

  @POST("/feedback/myChats")
  Future<FeedBackInfo> getFeedBackChats({
    @Query("typeId") int typeId,
    @Query("groupId") int groupId,
    @Query("limit") int limit,
  });

  @POST("/feedback/post")
  Future postFeedBack(@Query("typeId") int typeId, @Query("content") String content, {@Query("images") String images});

  @POST("/user/setAvatar")
  @Headers(<String, dynamic>{
    "content-type": "multipart/form-data",
  })
  Future<RespData<String>> setAvatar(@Part(name: "file") File file);
}
