import 'package:electronic_assistant/data/api/request/talk_request.dart';

import '../../utils/http_handler.dart';
import '../api/atmob_api.dart';
import '../api/request/agenda_request.dart';
import '../api/request/agenda_status_request.dart';
import '../api/response/agenda_list_all_response.dart';
import '../api/response/agenda_list_mine_response.dart';
import '../api/response/agenda_response.dart';

class AgendaRepository {
  AgendaRepository._();

  Future<AgendaResponse> agendaPage(int page, int pageSize,
      {int? startTime, int? endTime, TaskStatus? completeStatus}) {
    return atmobApi
        .agendaPage(AgendaRequest(page, pageSize,
            startTime: startTime,
            endTime: endTime,
            completeStatus: completeStatus?.value))
        .then(HttpHandler.handle(true));
  }

  Future<void> agendaFinish(int? id, bool complete) {
    return atmobApi
        .agendaFinish(AgendaStatusRequest(id, complete))
        .then(HttpHandler.handle(true));
  }

  Future<AgendaListAllResponse> agendaListAll(String talkId) {
    return atmobApi
        .agendaListAll(TalkRequest(talkId))
        .then(HttpHandler.handle(true));
  }

  Future<AgendaListMineResponse> agendaListMine(String talkId) {
    return atmobApi
        .agendaListMine(TalkRequest(talkId))
        .then(HttpHandler.handle(true));
  }
}

final agendaRepository = AgendaRepository._();
