package it.danieleverducci.openweddingapp.entities

import org.json.JSONException
import org.json.JSONObject
import java.util.*

class Token: Jsonable {
    val userId: Int
    val user: User
    val token: String

    @Throws(JSONException::class)
    constructor(jo: JSONObject) {
        this.userId = jo.getInt("userId")
        this.user = User(jo.getJSONObject("user"))
        this.token = jo.getString("token")
    }

    override fun toJson(): JSONObject {
        val jo = JSONObject()
        jo.put("userId", this.userId)
        jo.put("user", this.user.toJson())
        jo.put("token", this.token)
        return jo
    }

}