feat: add register functionality to AuthRepository
This commit is contained in:
parent
3ac9920e0f
commit
00799be513
|
|
@ -1,16 +1,29 @@
|
|||
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)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user