package com.example.wabi.domain.network

import android.util.Log
import com.example.wabi.model.responses.Response
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.auth.auth
import io.github.jan.supabase.auth.providers.builtin.Email
import jakarta.inject.Inject

class SupabaseServiceImpl @Inject constructor(private val supabase: SupabaseClient) : SupabaseService {
    override suspend fun signIn(email: String, password: String): Response {
        return try {
            var response = supabase.auth.signInWith(Email) {
                this.email = email
                this.password = password
            }
            Response(response.toString())
        } catch (e: Exception) {
            Log.d("error sign in", e.message.toString())
            Response("", e.message.toString())
        }
    }

    override suspend fun signOut(): Response {
        return try {
            var response = supabase.auth.signOut()
            Response(response.toString())
        } catch (e: Exception) {
            Log.d("error sign out", e.message.toString())
            Response("", e.message.toString())
        }
    }

    override suspend fun signUp(email: String) {
        TODO("Not yet implemented")
    }

    override suspend fun verifyEmail(email: String) {
        TODO("Not yet implemented")
    }

    override suspend fun updateUserData(
        email: String,
        password: String,
        nickname: String,
        theme: Int,
        imgeLink: String?
    ) {
        TODO("Not yet implemented")
    }

}