import '../app/constant.dart';
import '../models/auth_model.dart';
import 'base_repository.dart';

class AuthRepository extends BaseRepository {
  AuthRepository({required super.dio});

  Future<AuthModel> login({
    required String username,
    required String password,
  }) async {
    final param = {
      "username": username,
      "password": password

      // "username": "alhadad1",
      // "doctor_id": "2891",
      // "password": "3"
    };
    final service =
        "${Constant.baseUrl}v1/courier/login/login/?username=$username&password=$password";
    final resp = await post(param: param, service: service);
    final result = AuthModel(
      token: resp['data']["token"],
      model: AuthKurirModel.fromJson(resp["data"]),
    );
    return result;
  }

  Future<String> logout({
    required String M_UserID,
    required String M_UserUsername,
  }) async {
    final param = {
      "M_UserID": M_UserID,
      "M_UserUsername": M_UserUsername
      // "username": "alhadad",
      // "doctor_id": "3101210841",
      // "password": "riau123"
    };

    final service = "${Constant.baseUrl}v1/courier/login/logout";
    final resp = await post(param: param, service: service);

    if (resp["status"] == "OK") {
      return resp['status'];
    } else {
      return resp['message'];
    }
  }
}
