package com.tt.honeyDue.models

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
 * Residence type lookup - matching Go API
 * Note: Go API returns arrays directly, no wrapper
 */
@Serializable
data class ResidenceType(
    val id: Int,
    val name: String
)

/**
 * Task frequency lookup - matching Go API TaskFrequencyResponse
 */
@Serializable
data class TaskFrequency(
    val id: Int,
    val name: String,
    val days: Int? = null,
    @SerialName("display_order") val displayOrder: Int = 0
) {
    // Helper for display
    val displayName: String
        get() = name
}

/**
 * Task priority lookup - matching Go API TaskPriorityResponse
 */
@Serializable
data class TaskPriority(
    val id: Int,
    val name: String,
    val level: Int = 0,
    val color: String = "",
    @SerialName("display_order") val displayOrder: Int = 0
) {
    // Helper for display
    val displayName: String
        get() = name
}

/**
 * Task category lookup - matching Go API TaskCategoryResponse
 */
@Serializable
data class TaskCategory(
    val id: Int,
    val name: String,
    val description: String = "",
    val icon: String = "",
    val color: String = "",
    @SerialName("display_order") val displayOrder: Int = 0
)

/**
 * Contractor specialty lookup
 */
@Serializable
data class ContractorSpecialty(
    val id: Int,
    val name: String,
    val description: String? = null,
    val icon: String? = null,
    @SerialName("display_order") val displayOrder: Int = 0
)

/**
 * Minimal contractor info for task references
 */
@Serializable
data class ContractorMinimal(
    val id: Int,
    val name: String,
    val company: String? = null
)

/**
 * Static data response - all lookups in one call
 * Note: This may need adjustment based on Go API implementation
 */
@Serializable
data class StaticDataResponse(
    @SerialName("residence_types") val residenceTypes: List<ResidenceType>,
    @SerialName("task_frequencies") val taskFrequencies: List<TaskFrequency>,
    @SerialName("task_priorities") val taskPriorities: List<TaskPriority>,
    @SerialName("task_categories") val taskCategories: List<TaskCategory>,
    @SerialName("contractor_specialties") val contractorSpecialties: List<ContractorSpecialty>
)

/**
 * Unified seeded data response - all lookups + task templates in one call
 * Supports ETag-based conditional fetching for efficient caching
 */
@Serializable
data class SeededDataResponse(
    @SerialName("residence_types") val residenceTypes: List<ResidenceType>,
    @SerialName("task_categories") val taskCategories: List<TaskCategory>,
    @SerialName("task_priorities") val taskPriorities: List<TaskPriority>,
    @SerialName("task_frequencies") val taskFrequencies: List<TaskFrequency>,
    @SerialName("contractor_specialties") val contractorSpecialties: List<ContractorSpecialty>,
    @SerialName("task_templates") val taskTemplates: TaskTemplatesGroupedResponse
)

// Legacy wrapper responses for backward compatibility
// These can be removed once all code is migrated to use arrays directly

@Serializable
data class ResidenceTypeResponse(
    val count: Int,
    val results: List<ResidenceType>
)

@Serializable
data class TaskFrequencyResponse(
    val count: Int,
    val results: List<TaskFrequency>
)

@Serializable
data class TaskPriorityResponse(
    val count: Int,
    val results: List<TaskPriority>
)

@Serializable
data class TaskCategoryResponse(
    val count: Int,
    val results: List<TaskCategory>
)

@Serializable
data class ContractorSpecialtyResponse(
    val count: Int,
    val results: List<ContractorSpecialty>
)
