-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from everymeals/feature/school_auth_screen
[Feature/school_auth_screen]: 인증 이메일 API 연동 작업
- Loading branch information
Showing
16 changed files
with
261 additions
and
53 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
data/src/main/java/com/everymeal/data/datasource/auth/AuthRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package com.everymeal.data.datasource.auth | ||
|
||
import com.everymeal.domain.model.auth.Email | ||
import com.everymeal.domain.model.auth.EmailAuthToken | ||
|
||
interface AuthRemoteDataSource { | ||
suspend fun postEmail(email: Email): Result<String> | ||
suspend fun postEmail(email: Email): Result<EmailAuthToken> | ||
suspend fun verifyToken(emailAuthToken: String, emailAuthValue: String): Result<Boolean> | ||
} |
14 changes: 11 additions & 3 deletions
14
data/src/main/java/com/everymeal/data/datasource/auth/AuthRemoteRemoteDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
package com.everymeal.data.datasource.auth | ||
|
||
import com.everymeal.data.model.auth.EmailResponse | ||
import com.everymeal.data.model.auth.toEmail | ||
import com.everymeal.data.model.auth.toEmailAuthToken | ||
import com.everymeal.data.model.auth.toEmailRequest | ||
import com.everymeal.data.model.unwrapData | ||
import com.everymeal.data.service.auth.AuthApi | ||
import com.everymeal.domain.model.auth.Email | ||
import com.everymeal.domain.model.auth.EmailAuthToken | ||
import javax.inject.Inject | ||
|
||
class AuthRemoteRemoteDataSourceImpl @Inject constructor( | ||
private val authApi: AuthApi | ||
) : AuthRemoteDataSource { | ||
|
||
override suspend fun postEmail(email: Email): Result<String> = runCatching { | ||
authApi.postEmail(email.toEmailRequest()) | ||
}.unwrapData() | ||
override suspend fun postEmail(email: Email): Result<EmailAuthToken> = runCatching { | ||
authApi.postEmail(email.toEmailRequest()).data.toEmailAuthToken() | ||
} | ||
|
||
override suspend fun verifyToken(emailAuthToken: String, emailAuthValue: String) = runCatching { | ||
authApi.verifyToken(emailAuthToken, emailAuthValue).data | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
data/src/main/java/com/everymeal/data/model/auth/EmailResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.everymeal.data.model.auth | ||
|
||
import com.everymeal.domain.model.auth.EmailAuthToken | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class EmailResponse( | ||
@SerialName("emailAuthToken") val emailAuthToken: String, | ||
) | ||
|
||
fun EmailResponse.toEmailAuthToken(): EmailAuthToken = | ||
EmailAuthToken(emailAuthToken = emailAuthToken) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
domain/src/main/java/com/everymeal/domain/model/auth/EmailAuthToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.everymeal.domain.model.auth | ||
|
||
data class EmailAuthToken( | ||
val emailAuthToken: String | ||
) |
4 changes: 3 additions & 1 deletion
4
domain/src/main/java/com/everymeal/domain/repository/auth/AuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.everymeal.domain.repository.auth | ||
|
||
import com.everymeal.domain.model.auth.Email | ||
import com.everymeal.domain.model.auth.EmailAuthToken | ||
|
||
interface AuthRepository { | ||
suspend fun postEmail(email: Email): Result<String> | ||
suspend fun postEmail(email: Email): Result<EmailAuthToken> | ||
suspend fun verifyToken(emailAuthToken: String, emailAuthValue: String): Result<Boolean> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
domain/src/main/java/com/everymeal/domain/usecase/auth/VerifyTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.everymeal.domain.usecase.auth | ||
|
||
import com.everymeal.domain.repository.auth.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class VerifyTokenUseCase @Inject constructor( | ||
private val authRepository: AuthRepository | ||
) { | ||
suspend operator fun invoke( | ||
emailAuthToken: String, | ||
emailAuthValue: String | ||
): Result<Boolean> { | ||
return authRepository.verifyToken(emailAuthToken, emailAuthValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.