package com.example.elva.data.repository

import com.example.elva.data.api.ProfileApiService
import com.example.elva.data.models.profile.ProfileUpdateRequest
import com.example.elva.data.models.profile.UserProfile
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class ProfileRepository @Inject constructor(
    private val profileApi: ProfileApiService
) {

    suspend fun getProfile(): Result<UserProfile> {
        return try {
            val profile = profileApi.getProfile()
            Result.success(profile)
        } catch (e: Exception) {
            Result.failure(e)
        }
    }

    suspend fun updateProfile(request: ProfileUpdateRequest): Result<UserProfile> {
        return try {
            val updatedProfile = profileApi.updateProfile(request)
            Result.success(updatedProfile)
        } catch (e: Exception) {
            Result.failure(e)
        }
    }
}

