package com.omixlab.lckcontrol.shared

import android.os.Parcel
import android.os.Parcelable

data class StreamDestination(
    val service: String,
    val linkedAccountId: String = "",
    val title: String,
    val description: String = "",
    val privacyStatus: String = "public",
    val gameId: String = "",
    val tags: List<String> = emptyList(),
    val rtmpUrl: String = "",
    val streamKey: String = "",
    val broadcastId: String = "",
    val status: String = "PENDING",
) : Parcelable {

    constructor(parcel: Parcel) : this(
        service = parcel.readString()!!,
        linkedAccountId = parcel.readString() ?: "",
        title = parcel.readString()!!,
        description = parcel.readString() ?: "",
        privacyStatus = parcel.readString() ?: "public",
        gameId = parcel.readString() ?: "",
        tags = parcel.createStringArrayList() ?: emptyList(),
        rtmpUrl = parcel.readString() ?: "",
        streamKey = parcel.readString() ?: "",
        broadcastId = parcel.readString() ?: "",
        status = parcel.readString() ?: "PENDING",
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(service)
        parcel.writeString(linkedAccountId)
        parcel.writeString(title)
        parcel.writeString(description)
        parcel.writeString(privacyStatus)
        parcel.writeString(gameId)
        parcel.writeStringList(tags)
        parcel.writeString(rtmpUrl)
        parcel.writeString(streamKey)
        parcel.writeString(broadcastId)
        parcel.writeString(status)
    }

    override fun describeContents(): Int = 0

    companion object CREATOR : Parcelable.Creator<StreamDestination> {
        override fun createFromParcel(parcel: Parcel) = StreamDestination(parcel)
        override fun newArray(size: Int) = arrayOfNulls<StreamDestination>(size)
    }
}
