Skip to content

Commit

Permalink
[FEATURE/#23] login api
Browse files Browse the repository at this point in the history
  • Loading branch information
chattymin committed Jul 30, 2024
1 parent 4eddacf commit ad2e8ac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
4 changes: 4 additions & 0 deletions data/src/main/java/com/kkkk/data/dataSource/AuthDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ interface AuthDataSource {
suspend fun postReissueTokens(
authorization: String,
): BaseResponse<AuthTokenDto>

suspend fun postLogin(
deviceTag: String,
): BaseResponse<AuthTokenDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.kkkk.data.dataSourceImpl

import com.kkkk.data.dataSource.AuthDataSource
import com.kkkk.data.dto.BaseResponse
import com.kkkk.data.dto.request.TokenRequestDto
import com.kkkk.data.dto.response.AuthTokenDto
import com.kkkk.data.service.AuthService
import javax.inject.Inject
Expand All @@ -15,4 +14,8 @@ constructor(
override suspend fun postReissueTokens(
authorization: String
): BaseResponse<AuthTokenDto> = authService.postReissueTokens(authorization)

override suspend fun postLogin(
deviceTag: String
): BaseResponse<AuthTokenDto> = authService.postLogin(deviceTag)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ class AuthRepositoryImpl
constructor(
private val authDataSource: AuthDataSource,
) : AuthRepository {
override suspend fun postReissueTokens(
authorization: String,
): Result<AuthTokenModel> =
runCatching {
authDataSource.postReissueTokens(
authorization,
).data.toModel()
}
override suspend fun reissueTokens(
authorization: String
): Result<AuthTokenModel> = runCatching {
authDataSource.postReissueTokens(
authorization,
).data.toModel()
}

override suspend fun login(
deviceTag: String
): Result<AuthTokenModel> = runCatching {
authDataSource.postLogin(deviceTag).data.toModel()
}
}
3 changes: 1 addition & 2 deletions data/src/main/java/com/kkkk/data/service/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import retrofit2.http.Header
import retrofit2.http.POST

interface AuthService {
// TODO: 서버 나오면 수정
@POST("api/users/reissue")
@POST("api/v1/reissue")
suspend fun postReissueTokens(
@Header("Authorization") authorization: String
): BaseResponse<AuthTokenDto>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package com.kkkk.domain.repository
import com.kkkk.domain.entity.response.AuthTokenModel

interface AuthRepository {
suspend fun postReissueTokens(
suspend fun reissueTokens(
authorization: String
): Result<AuthTokenModel>

suspend fun login(
deviceTag: String
): Result<AuthTokenModel>
}

0 comments on commit ad2e8ac

Please sign in to comment.