import 'package:betting/commom/constants/api_constant.dart';
import 'package:betting/data/base_service/api_response.dart';
import 'package:betting/data/base_service/respone_data.dart';
import 'package:betting/data/model/base_model.dart';
import 'package:betting/data/model/res/profile/profile.dart';
import '../../base_service/api_service.dart';


class ProfileRepo {
  Future<ResponseData<Profile>> getProfile() async {
    ResponseData<Profile> streamEvent = ResponseData(state: Status.LOADING);

    var param = <String, dynamic>{};
    ApiResponse<BaseModel> apiResponse =
    await ApiService(ApiConstants.API_USER_PROFILE, request: param)
        .request(Request.GET);

    if (apiResponse.status == Status.SUCCESS) {
      Profile dataRes = Profile.fromJson(apiResponse.data?.data);
      streamEvent = ResponseData(state: Status.SUCCESS, object: dataRes);
    }

    if (apiResponse.status == Status.ERROR) {
      streamEvent = ResponseData(
          state: Status.ERROR,
          errorCode: apiResponse.error,
          message: apiResponse.error?.message);
    }
    return streamEvent;
  }


}