package de.sebse.fuplanner2.database

import com.beust.klaxon.Klaxon
import com.beust.klaxon.KlaxonException


data class Attachment (
    val url: String,
    val name: String,
    val mimeType: String
) {
    fun toJsonString(): String {
        return Klaxon().toJsonString(this)
    }

    companion object {
        fun fromString(json: String): Attachment? {
            return try {
                Klaxon().parse<Attachment>(json)
            } catch (e: KlaxonException) {
                null
            }
        }
    }
}
