package de.sebse.fuplanner2.database

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.beust.klaxon.JsonObject
import com.beust.klaxon.Parser

@Entity
data class Notification (
    @PrimaryKey(autoGenerate = true) val uid: Int? = null,
    val created: Long,
    val read: Boolean,
    val channelId: String,
    val data: String
) {
    fun getJsonData(): JsonObject? {
        return try {
            Parser.default().parse(StringBuilder(this.data)) as JsonObject
        } catch (e: Throwable) {
            null
        }
    }
}
