package pl.firmatpp.kierowca.data.model

data class RequestOtpBody(val phoneNumber: String)

data class VerifyOtpBody(
    val phoneNumber: String,
    val code: String,
    val deviceName: String,
    val device: DriverDeviceInfo,
)

data class DriverDeviceInfo(
    val deviceId: String,
    val androidId: String?,
    val brand: String?,
    val manufacturer: String?,
    val model: String?,
    val device: String?,
    val product: String?,
    val androidVersion: String?,
    val sdkInt: Int,
    val appVersion: String?,
    val serialNumber: String?,
)

data class OtpResponse(
    val ok: Boolean,
    val phoneMasked: String?,
    val expiresInSeconds: Int?,
)

data class VerifyOtpResponse(
    val ok: Boolean,
    val accessToken: String?,
    val expiresAt: String?,
    val driver: DriverDto?,
)

data class DriverDto(
    val id: String,
    val displayName: String,
    val anonymousLabel: String?,
)

data class BootstrapResponse(
    val session: DriverSessionDto,
    val routes: RoutesBucketDto,
    val driverAppSettings: DriverAppSettingsDto?,
    val syncState: SyncStateResponse? = null,
)

data class DriverAppSettingsDto(
    val minDate: String,
    val maxDate: String,
    val today: String,
    val selectedDate: String,
    val maxPastDays: Int,
    val autoRefreshSeconds: Int,
    val allowGalleryUploads: Boolean?,
    val allowRouteCompletion: Boolean?,
    val requirePreciseLocationForPhotos: Boolean?,
)

data class DriverSessionDto(
    val driver: DriverDto,
    val lastSyncAt: String,
)

data class RoutesBucketDto(
    val today: List<DriverRouteDto> = emptyList(),
)

data class RouteResponse(
    val route: DriverRouteDto,
    val syncState: SyncStateResponse? = null,
)

data class CompleteRouteResponse(
    val ok: Boolean,
    val alreadyCompleted: Boolean,
    val message: String?,
    val completedAt: String?,
    val route: DriverRouteDto,
)

data class SyncStateResponse(
    val scopes: List<SyncScopeDto> = emptyList(),
)

data class SyncScopeDto(
    val scope: String,
    val date: String? = null,
    val routeId: String? = null,
    val version: Long,
    val checksum: String,
    val computedAt: String,
)

data class BroadcastAuthBody(
    val socket_id: String,
    val channel_name: String,
)

data class BroadcastAuthResponse(
    val auth: String,
)

data class PushTokenBody(
    val token: String,
    val platform: String = "android",
)

data class RealtimeStatusBody(
    val reverbStatus: String,
    val socketId: String? = null,
    val error: String? = null,
)

data class DriverRouteDto(
    val id: String,
    val startsAt: String,
    val originName: String,
    val destinationName: String,
    val contractorName: String,
    val contractName: String?,
    val contractCode: String?,
    val relationLabel: String,
    val status: String,
    val distanceKm: Double?,
    val notes: String?,
    val truck: TruckDto?,
    val completedAt: String? = null,
    val completedByDriver: DriverDto? = null,
    val originNavigation: NavigationPointDto? = null,
    val destinationNavigation: NavigationPointDto? = null,
    val photos: List<RoutePhotoDto> = emptyList(),
)

data class TruckDto(
    val id: String,
    val registration: String?,
    val trailerRegistration: String? = null,
    val name: String?,
)

data class NavigationPointDto(
    val id: String,
    val label: String?,
    val latitude: Double?,
    val longitude: Double?,
)

data class RoutePhotoDto(
    val id: String,
    val routeId: String,
    val clientRequestId: String? = null,
    val contentSha256: String? = null,
    val source: String,
    val mimeType: String?,
    val size: Long,
    val url: String,
    val takenAt: String?,
    val latitude: Double?,
    val longitude: Double?,
    val locationAccuracyMeters: Double?,
    val createdAt: String?,
    val canDelete: Boolean = false,
    val deleteUntil: String? = null,
)

data class PhotoUploadResponse(
    val photo: RoutePhotoDto,
    val receipt: PhotoUploadReceiptDto,
)

data class PhotoUploadReceiptDto(
    val clientRequestId: String,
    val serverPhotoId: String,
    val contentSha256: String,
    val storedAt: String?,
)
