import 'package:injectable/injectable.dart';
import 'package:location/base/app_base_request.dart';
import 'package:location/data/api/atmob_api.dart';

import '../../utils/http_handler.dart';
import '../api/request/query_track_request.dart';
import '../api/response/query_track_response.dart';

@lazySingleton
class TrackRepository {
  final AtmobApi atmobApi;

  TrackRepository(this.atmobApi);

  Future<QueryTrackResponse> queryVirtualTrack() {
    return atmobApi
        .queryVirtualTrack(AppBaseRequest())
        .then(HttpHandler.handle(true));
  }

  Future<QueryTrackResponse> queryTrack(
      {required int? startTime,
      required int? endTime,
      required String? userId}) {
    return atmobApi
        .queryTrack(QueryTrackRequest(
            startTime: startTime, endTime: endTime, userId: userId))
        .then(HttpHandler.handle(true));
  }
}
