package com.ponzischeme89.memby.update

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

/** Subset of a Gitea (GitHub-compatible) release we care about. */
@Serializable
data class GiteaRelease(
    @SerialName("tag_name") val tagName: String = "",
    @SerialName("name") val name: String = "",
    @SerialName("body") val body: String = "",
    @SerialName("draft") val draft: Boolean = false,
    @SerialName("prerelease") val prerelease: Boolean = false,
    @SerialName("assets") val assets: List<GiteaAsset> = emptyList(),
)

@Serializable
data class GiteaAsset(
    @SerialName("name") val name: String = "",
    @SerialName("browser_download_url") val browserDownloadUrl: String = "",
)

/**
 * A plain update manifest, for hosting APKs on a web server or NAS rather than a Gitea
 * release. Point the update URL at the manifest itself:
 *
 * ```json
 * {
 *   "version": "0.1.53",
 *   "apkUrl": "https://nas.example.com/memby/memby-0.1.53.apk",
 *   "notes": "What changed in this build"
 * }
 * ```
 *
 * [apkUrl] may be relative ("memby-0.1.53.apk"), in which case it is resolved against
 * the manifest's own URL — so moving the whole folder needs no edit.
 */
@Serializable
data class UpdateManifest(
    val version: String = "",
    val apkUrl: String = "",
    val notes: String = "",
)
