// 用户
import 'package:news_getx/data/model/user.dart';
import 'package:news_getx/utils/http.dart';

class UserAPI {
  /// 登录
  static Future<UserLoginResponse> login(UserLoginRequest? data) async {
    var response = await HttpUtil().post(
      "/user/login",
      data: data?.toJson(),
    );
    return UserLoginResponse.fromJson(response);
  }

  /// 注册
  static Future<UserRegisterRequest> register(UserRegisterRequest request, {
    UserRegisterRequest? data,
  }) async {
    var response = await HttpUtil().post(
      '/user/register',
      data: data?.toJson(),
    );
    return UserRegisterRequest.fromJson(response);
  }

  /// Profile
  static Future<UserLoginResponse> profile() async {
    var response = await HttpUtil().post(
      '/user/profile',
    );
    return UserLoginResponse.fromJson(response);
  }

  /// Logout
  static Future logout() async {
    return await HttpUtil().post(
      '/user/logout',
    );
  }
}
