import {QueryDocumentSnapshot, Timestamp} from "firebase-admin/firestore"; import {cleanEntityId} from "../../core/data/entities/entity_utils"; export type DriverStatus = "offline" | "online" | "busy"; export interface DriverEntityData { id?: string; vehicleMake: string; vehicleModel: string; vehicleColor: string; vehiclePlate: string; photoUrl?: string; status: DriverStatus; currentLat?: number; currentLng?: number; geohash?: string; rating: number; ratingCount: number; createdAt: Timestamp; updatedAt: Timestamp; } export type NewDriverEntityData = Omit; export interface DriverEntity extends DriverEntityData {} export class DriverEntity { constructor({ id, vehicleMake, vehicleModel, vehicleColor, vehiclePlate, photoUrl, status, currentLat, currentLng, geohash, rating, ratingCount, createdAt, updatedAt, }: DriverEntityData) { this.id = id; this.vehicleMake = vehicleMake; this.vehicleModel = vehicleModel; this.vehicleColor = vehicleColor; this.vehiclePlate = vehiclePlate; this.photoUrl = photoUrl; this.status = status; this.currentLat = currentLat; this.currentLng = currentLng; this.geohash = geohash; this.rating = rating; this.ratingCount = ratingCount; this.createdAt = createdAt; this.updatedAt = updatedAt; } static fromDocument(doc: QueryDocumentSnapshot): DriverEntity { const data = doc.data() as DriverEntityData; data.id = doc.id; return new DriverEntity(data); } } export class DriverAdapter { static toMap(data: Partial): { [key: string]: unknown } { return cleanEntityId(data); } }