import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart';
import 'package:hoshan/data/model/assistant_personal_info_model.dart';
import 'package:hoshan/data/repository/bot_repository.dart';

part 'personal_assistant_info_state.dart';

class PersonalAssistantInfoCubit extends Cubit<PersonalAssistantInfoState> {
  PersonalAssistantInfoCubit() : super(PersonalAssistantInfoInitial());

  Future getInfo(int id) async {
    emit(PersonalAssistantInfoLoading());
    try {
      final response = await BotRepository.getAssistantPersonalInfo(id);
      emit(PersonalAssistantInfoSucess(info: response.assistantPersonalInfo!));
    } on DioException catch (e) {
      emit(PersonalAssistantInfoFail());
      if (kDebugMode) {
        print('Dio Error is: $e');
      }
    }
  }
}
