package com.hermes.app.domain

import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable

@Serializable
data class HermesSessionStartRequest(
    val externalRef: String? = null,
    val localeCode: String? = null,
    val devicePlatform: String? = null,
    val deviceModel: String? = null,
    val osVersion: String? = null,
    val appVersion: String? = null,
    val experimentVariant: String? = null,
)

@Serializable
data class HermesSessionResponse(
    val sessionId: String,
    val userId: String,
    val startedAt: Instant,
    val endedAt: Instant? = null,
    val experimentVariant: String,
    val appVersion: String,
    val deviceModel: String? = null,
    val osVersion: String? = null,
    val localeCode: String,
    val devicePlatform: String,
)

@Serializable
data class HermesHealthResponse(
    val status: String,
    val serviceName: String,
    val environment: String,
    val version: String,
    val uptimeMs: Long,
    val serverTime: Instant,
    val databaseReady: Boolean,
    val redisReady: Boolean,
)

@Serializable
data class HermesEvent(
    val id: String,
    val sportType: String,
    val sourceRef: String,
    val titleEn: String,
    val titleSv: String,
    val status: String,
    val previewStartMs: Int,
    val previewEndMs: Int,
    val revealStartMs: Int,
    val revealEndMs: Int,
    val lockAt: Instant,
    val settleAt: Instant,
)

@Serializable
data class HermesEventMedia(
    val id: String,
    val eventId: String,
    val mediaType: String,
    val hlsMasterUrl: String,
    val posterUrl: String? = null,
    val durationMs: Int,
    val previewStartMs: Int,
    val previewEndMs: Int,
    val revealStartMs: Int,
    val revealEndMs: Int,
)

@Serializable
data class HermesEventManifest(
    val event: HermesEvent,
    val media: List<HermesEventMedia>,
    val markets: List<HermesMarket>,
)

@Serializable
data class HermesOutcome(
    val id: String,
    val marketId: String,
    val outcomeCode: String,
    val labelKey: String,
    val sortOrder: Int,
)

@Serializable
data class HermesMarket(
    val id: String,
    val eventId: String,
    val questionKey: String,
    val marketType: String,
    val status: String,
    val lockAt: Instant,
    val settlementRuleKey: String,
    val outcomes: List<HermesOutcome>,
)

@Serializable
data class HermesOutcomeOdds(
    val id: String,
    val oddsVersionId: String,
    val outcomeId: String,
    val decimalOdds: Double,
    val fractionalNum: Int,
    val fractionalDen: Int,
)

@Serializable
data class HermesOddsVersion(
    val id: String,
    val marketId: String,
    val versionNo: Int,
    val createdAt: Instant,
    val isCurrent: Boolean,
    val odds: List<HermesOutcomeOdds>,
)

@Serializable
data class HermesBetIntentRequest(
    val sessionId: String,
    val eventId: String,
    val marketId: String,
    val outcomeId: String,
    val idempotencyKey: String,
    val clientSentAt: Instant,
)

@Serializable
data class HermesBetIntentResponse(
    val id: String,
    val accepted: Boolean,
    val acceptanceCode: String,
    val acceptedOddsVersionId: String? = null,
    val serverReceivedAt: Instant,
)

@Serializable
data class HermesSettlement(
    val id: String,
    val marketId: String,
    val settledAt: Instant,
    val winningOutcomeId: String,
)

@Serializable
data class HermesAnalyticsAttributeInput(
    val key: String,
    val value: String,
)

@Serializable
data class HermesAnalyticsEventInput(
    val eventName: String,
    val occurredAt: Instant,
    val attributes: List<HermesAnalyticsAttributeInput>? = null,
)

@Serializable
data class HermesAnalyticsBatchRequest(
    val events: List<HermesAnalyticsEventInput>,
)

@Serializable
data class HermesExperimentConfig(
    val variant: String,
    val featureFlags: Map<String, Boolean>,
)

@Serializable
data class HermesLocalizationBundle(
    val localeCode: String,
    val values: Map<String, String>,
)

data class HermesRound(
    val event: HermesEvent,
    val media: HermesEventMedia,
    val market: HermesMarket,
    val oddsVersion: HermesOddsVersion,
    val settlement: HermesSettlement,
)
