package com.zaojiao.app.data.remote

import com.zaojiao.app.core.common.state.DataState
import com.zaojiao.app.core.http.common.dataStateCatch
import com.zaojiao.app.data.model.TokenModel
import com.zaojiao.app.data.remote.api.LoginApi
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class RemoteLoginData @Inject constructor(
    private val loginApi: LoginApi,
) {
    suspend fun loginBySms(phone: String, code: String): DataState<TokenModel?> {
        return dataStateCatch { loginApi.loginBySms(phone, code) }
    }

    suspend fun loginByWechat(code: String): DataState<TokenModel?> {
        return dataStateCatch { loginApi.loginByWechat(code) }
    }

    suspend fun loginByOneClick(code: String): DataState<TokenModel?> {
        return dataStateCatch { loginApi.loginByOneClick(code) }
    }
}