package com.prodhack.moscow2025.data.repImplementations

import com.prodhack.moscow2025.data.base.BaseRepository
import com.prodhack.moscow2025.data.data_providers.api.ApiKtorClient
import com.prodhack.moscow2025.data.dto.FcmTokenDTO
import com.prodhack.moscow2025.domain.interfaces.FCMRepository
import io.ktor.client.request.setBody
import io.ktor.client.request.url
import io.ktor.http.ContentType
import io.ktor.http.HttpMethod
import io.ktor.http.contentType
import org.koin.core.annotation.Single

@Single
class FCMRepositoryImpl(
	val ktorClient: ApiKtorClient
) : FCMRepository, BaseRepository() {

	override val defaultKtorClient = ktorClient.client

	override suspend fun sendFCMToken(token: String) {
		networkRequest<String> {
			method = HttpMethod.Post
			url("/notifications/register_device")
			setBody(FcmTokenDTO(token))
			contentType(ContentType.Application.Json)
		}
	}
}