package com.hanwha.morakmorak.data.local.preferences

import android.content.SharedPreferences

/**
 * Created by aaron on 2019-10-02
 */
class UserPreferences(private val sharedPreferences: SharedPreferences) {

    /**
     * 사용자 ID
     */
    var userId: Int
        get() = sharedPreferences.getInt(KEY_PREFS_USER_ID, 0)
        set(value) = sharedPreferences.edit().putInt(KEY_PREFS_USER_ID, value).apply()

    /**
     * 사용자 Token(JWT)
     */
    var userToken: String
        get() = sharedPreferences.getString(KEY_PREFS_USER_TOKEN, "")
        set(value) = sharedPreferences.edit().putString(KEY_PREFS_USER_TOKEN, value).apply()

    companion object {
        const val KEY_PREFS_USER_ID = "prefs_user_id"
        const val KEY_PREFS_USER_TOKEN = "prefs_user_token"
    }
}