package com.github.nullptroma.wallenc.domain.vault.network.yandexuserinfo.repository

import com.github.nullptroma.wallenc.domain.vault.network.yandexuserinfo.YandexUserInfoApi
import com.github.nullptroma.wallenc.domain.vault.network.yandexuserinfo.YandexUserInfoDto
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext

class YandexUserInfoRepository(
    private val api: YandexUserInfoApi,
    private val ioDispatcher: CoroutineDispatcher
) {
    suspend fun userInfo(accessToken: String): YandexUserInfoDto = withContext(ioDispatcher) {
        api.userInfo(format = "json", authorization = "OAuth $accessToken")
    }
}
