import type {
  Vehicle,
  VehicleStats,
  UpdateVehiclePayload,
  VehicleProviderOption,
  LinkbycarDisconnectResult,
  LinkbycarCompanySummary,
  LinkbycarBulkDisconnectResult,
  LinkbycarCompanyVerification,
  LinkbycarCompaniesPage,
  LinkbycarQueuedResult,
} from "@/domain/entities/vehicle";
import type { BackendPaginatedData, PaginationQueryParams } from "@/shared/types";

export interface VehicleRepository {
  findAll(params: PaginationQueryParams): Promise<BackendPaginatedData<Vehicle>>;
  findById(id: number): Promise<Vehicle>;
  update(id: number, data: UpdateVehiclePayload): Promise<Vehicle>;
  delete(id: number): Promise<void>;
  getStats(): Promise<VehicleStats>;
  connectLinkbycar(vehicleId: number): Promise<void>;
  testEligibility(vehicleId: number): Promise<void>;

  /** Remove one vehicle from LinkByCar. Synchronous; works on archived vehicles too. */
  disconnectLinkbycar(vehicleId: number): Promise<LinkbycarDisconnectResult>;

  /** Company-wide LinkByCar counts. Also the progress read while a bulk disconnect drains. */
  getCompanyLinkbycarSummary(companyId: number): Promise<LinkbycarCompanySummary>;

  /** Queue LinkByCar removal for a whole company (processed off-request). */
  disconnectCompanyLinkbycar(companyId: number, includeAll: boolean): Promise<LinkbycarBulkDisconnectResult>;

  /** Ask LinkByCar which of the company vehicles it still holds. Slower: it pages the provider listing. */
  verifyCompanyLinkbycar(companyId: number): Promise<LinkbycarCompanyVerification>;
  getProviderOptions(): Promise<VehicleProviderOption[]>;

  /** The companies with where their fleet stands with LinkByCar: filters status, stage, search, sort; paginated. */
  listLinkbycarCompanies(params: PaginationQueryParams): Promise<LinkbycarCompaniesPage>;

  /** Queue an eligibility test of the company vehicles with a VIN not linked yet. Free. */
  testCompanyEligibility(companyId: number): Promise<LinkbycarQueuedResult>;

  /** Queue the connection of the company eligible vehicles: one paid subscription each. `expected` is the count confirmed. */
  connectCompanyEligible(companyId: number, expected: number): Promise<LinkbycarQueuedResult>;
}
