package com.syaroful.agrilinkvocpro.data.repository

import com.syaroful.agrilinkvocpro.data.model.LoginResponse
import com.syaroful.agrilinkvocpro.data.model.RegisterResponse
import com.syaroful.agrilinkvocpro.data.network.ApiService
import com.syaroful.agrilinkvocpro.data.network.LoginRequest
import com.syaroful.agrilinkvocpro.data.network.RegisterRequest
import retrofit2.Response

class AuthRepository(
    private val apiService: ApiService
) {
    suspend fun login(username: String, password: String): Response<LoginResponse> {
        val credential = okhttp3.Credentials.basic(username, password)
        val requestBody = LoginRequest(username, password)
        return apiService.login(authHeader = credential, body = requestBody)
    }

    suspend fun register(
        username: String,
        password: String,
        email: String,
        fullname: String
    ): Response<RegisterResponse> {
        val requestBody = RegisterRequest(username, password, email, fullname)
        return apiService.register(requestBody)
    }

}