package com.tt.honeyDue.models

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

/**
 * Task completion create request matching Go API CreateTaskCompletionRequest
 */
@Serializable
data class TaskCompletionCreateRequest(
    @SerialName("task_id") val taskId: Int,
    @SerialName("completed_at") val completedAt: String? = null,  // Defaults to now on server
    val notes: String? = null,
    @SerialName("actual_cost") val actualCost: Double? = null,
    val rating: Int? = null,  // 1-5 star rating
    @SerialName("upload_ids") val uploadIds: List<Int>? = null      // pending_uploads.id values from /api/uploads/presign + direct B2 POST
)

/**
 * Presigned upload session — request body for POST /api/uploads/presign.
 *
 * Category: "completion" | "document_image" | "document_file"
 * ContentType: the MIME type the client will upload (must match the policy
 * exactly when POSTing to B2).
 * ContentLength: byte count of the upload (server permits ±256 bytes slack).
 */
@Serializable
data class PresignUploadRequest(
    val category: String,
    @SerialName("content_type") val contentType: String,
    @SerialName("content_length") val contentLength: Long
)

/**
 * Presigned upload session — response from POST /api/uploads/presign.
 *
 * The client uses [uploadUrl] + [fields] to perform a multipart/form-data
 * POST directly to B2, then passes [id] back in the upload_ids[] field of
 * the next /api/task-completions/ or /api/documents/ create call.
 */
@Serializable
data class PresignUploadResponse(
    val id: Int,
    @SerialName("upload_url") val uploadUrl: String,
    val fields: Map<String, String>,
    val key: String,
    @SerialName("expires_at") val expiresAt: String
)

