e-ntfy-android/app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt
2021-11-07 13:13:32 -05:00

19 lines
544 B
Kotlin

package io.heckel.ntfy.msg
import com.google.gson.Gson
import io.heckel.ntfy.data.Notification
class NotificationParser {
private val gson = Gson()
fun fromString(subscriptionId: Long, s: String): Notification {
val n = gson.fromJson(s, NotificationData::class.java) // Indirection to prevent accidental field renames, etc.
return Notification(n.id, subscriptionId, n.time, n.message)
}
private data class NotificationData(
val id: String,
val time: Long,
val message: String
)
}