Skip to content

Commit

Permalink
[#30] 로그인 기능 추가 - converter 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-223 committed Sep 4, 2022
1 parent 286f0a8 commit 98fc308
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface AuthRepository {
suspend fun signIn(
idToken: String,
providerType: ProviderType
): ApiResult<Success<SignInResponse>>
): ApiResult<SignInResponse>

suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<Success<SignInResponse>>
suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<SignInResponse>
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.moyerun.moyeorun_android.login.data.impl

import com.moyerun.moyeorun_android.common.Lg
import com.moyerun.moyeorun_android.common.di.IODispatcher
import com.moyerun.moyeorun_android.login.ProviderType
import com.moyerun.moyeorun_android.login.data.AuthRepository
import com.moyerun.moyeorun_android.login.data.model.*
import com.moyerun.moyeorun_android.login.data.model.SignInResponse
import com.moyerun.moyeorun_android.login.data.model.SignUpRequest
import com.moyerun.moyeorun_android.network.MoyeorunNetworkDataSource
import com.moyerun.moyeorun_android.network.api.Success
import com.moyerun.moyeorun_android.network.calladapter.ApiResult
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
Expand All @@ -20,13 +19,13 @@ class AuthRepositoryImpl @Inject constructor(
override suspend fun signIn(
idToken: String,
providerType: ProviderType
): ApiResult<Success<SignInResponse>> {
): ApiResult<SignInResponse> {
return withContext(coroutineDispatcher) {
network.signIn(idToken = idToken, providerType = providerType)
}
}

override suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<Success<SignInResponse>> {
override suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<SignInResponse> {
return withContext(coroutineDispatcher) {
network.signUp(signUpRequest)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LoginViewModel @Inject constructor(
_isLoading.value = true
authRepository.signIn(idToken, providerType)
.onSuccess {
_loginEvent.event = if (it.data.isNewUser) {
_loginEvent.event = if (it.isNewUser) {
LoginEvent.NewUser(SignUpMetaData(idToken, providerType))
} else {
LoginEvent.RegisteredUser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface MoyeorunNetworkDataSource {
suspend fun signIn(
idToken: String,
providerType: ProviderType
): ApiResult<Success<SignInResponse>>
): ApiResult<SignInResponse>

suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<Success<SignInResponse>>
suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<SignInResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MoyeorunNetworkDataSourceImpl(
override suspend fun signIn(
idToken: String,
providerType: ProviderType
): ApiResult<Success<SignInResponse>> {
): ApiResult<SignInResponse> {
return moyeorunService.signIn(
SignInRequest(
idToken = idToken,
Expand All @@ -23,7 +23,7 @@ class MoyeorunNetworkDataSourceImpl(
)
}

override suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<Success<SignInResponse>> {
override suspend fun signUp(signUpRequest: SignUpRequest): ApiResult<SignInResponse> {
return moyeorunService.signUp(signUpRequest)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import retrofit2.http.POST
interface MoyeorunService {

@POST("/api/auth/sign-in")
suspend fun signIn(@Body signInRequest: SignInRequest): ApiResult<Success<SignInResponse>>
suspend fun signIn(@Body signInRequest: SignInRequest): ApiResult<SignInResponse>

@POST("/api/auth/sign-up")
suspend fun signUp(@Body signUpRequest: SignUpRequest): ApiResult<Success<SignInResponse>>
suspend fun signUp(@Body signUpRequest: SignUpRequest): ApiResult<SignInResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ProfileEditViewModel @Inject constructor(
authRepository.signUp(profileUiModel.value.toSignUpRequest(metaData))
.onSuccess {
_profileEvent.event = ProfileEvent.SUCCESS_SIGN_UP
Lg.d(it.data.toString())
Lg.d(it.toString())
}
.onFailure { throwable ->
when (throwable) {
Expand Down

0 comments on commit 98fc308

Please sign in to comment.