-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
174 additions
and
38 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
data/auth/src/main/java/org/sopt/official/data/auth/mapper/CertificateCodeMapper.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,21 @@ | ||
package org.sopt.official.data.auth.mapper | ||
|
||
import org.sopt.official.data.auth.remote.request.CertificateCodeRequest | ||
import org.sopt.official.data.auth.remote.response.CertificateCodeResponse | ||
import org.sopt.official.domain.auth.model.InformationWithCode | ||
import org.sopt.official.domain.auth.model.VerificationResult | ||
|
||
fun InformationWithCode.toRequest(): CertificateCodeRequest = | ||
CertificateCodeRequest( | ||
name = name, | ||
phone = phone, | ||
code = code, | ||
type = type | ||
) | ||
|
||
fun CertificateCodeResponse.toDomain() : VerificationResult = | ||
VerificationResult( | ||
isVerified = isVerified, | ||
name = name, | ||
phone = phone | ||
) |
11 changes: 0 additions & 11 deletions
11
data/auth/src/main/java/org/sopt/official/data/auth/mapper/CertificationMapper.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
data/auth/src/main/java/org/sopt/official/data/auth/mapper/CreateCodeMapper.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,11 @@ | ||
package org.sopt.official.data.auth.mapper | ||
|
||
import org.sopt.official.data.auth.remote.request.CreateCodeRequest | ||
import org.sopt.official.domain.auth.model.InitialInformation | ||
|
||
fun InitialInformation.toRequest(): CreateCodeRequest = | ||
CreateCodeRequest( | ||
name = name, | ||
phone = phone, | ||
type = type | ||
) |
14 changes: 14 additions & 0 deletions
14
data/auth/src/main/java/org/sopt/official/data/auth/model/BaseAuthResponse.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 org.sopt.official.data.auth.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseAuthResponse<T>( | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: T | ||
) |
13 changes: 13 additions & 0 deletions
13
data/auth/src/main/java/org/sopt/official/data/auth/model/NonDataBaseAuthResponse.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,13 @@ | ||
package org.sopt.official.data.auth.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class NonDataBaseAuthResponse( | ||
@SerialName("success") | ||
val success: Boolean, | ||
@SerialName("message") | ||
val message: String, | ||
val data: String? | ||
) |
18 changes: 13 additions & 5 deletions
18
data/auth/src/main/java/org/sopt/official/data/auth/remote/api/AuthApi.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,13 +1,21 @@ | ||
package org.sopt.official.data.auth.remote.api | ||
|
||
import org.sopt.official.data.auth.remote.request.CertificationNumberRequest | ||
import org.sopt.official.data.auth.remote.response.CertificationNumberResponse | ||
import org.sopt.official.data.auth.model.BaseAuthResponse | ||
import org.sopt.official.data.auth.model.NonDataBaseAuthResponse | ||
import org.sopt.official.data.auth.remote.request.CertificateCodeRequest | ||
import org.sopt.official.data.auth.remote.request.CreateCodeRequest | ||
import org.sopt.official.data.auth.remote.response.CertificateCodeResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
internal interface AuthApi { | ||
@POST("/api/v1/auth/phone") | ||
suspend fun postCertificationNumber( | ||
@Body request: CertificationNumberRequest, | ||
): CertificationNumberResponse | ||
suspend fun createCode( | ||
@Body request: CreateCodeRequest, | ||
): NonDataBaseAuthResponse | ||
|
||
@POST("/api/v1/auth/verify/phone") | ||
suspend fun certificateCode( | ||
@Body request: CertificateCodeRequest, | ||
): BaseAuthResponse<CertificateCodeResponse> | ||
} |
16 changes: 16 additions & 0 deletions
16
data/auth/src/main/java/org/sopt/official/data/auth/remote/request/CertificateCodeRequest.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,16 @@ | ||
package org.sopt.official.data.auth.remote.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class CertificateCodeRequest( | ||
@SerialName("name") | ||
val name: String?, | ||
@SerialName("phone") | ||
val phone: String, | ||
@SerialName("code") | ||
val code: String, | ||
@SerialName("type") | ||
val type: String, | ||
) |
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
14 changes: 14 additions & 0 deletions
14
...auth/src/main/java/org/sopt/official/data/auth/remote/response/CertificateCodeResponse.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 org.sopt.official.data.auth.remote.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class CertificateCodeResponse( | ||
@SerialName("isVerified") | ||
val isVerified: Boolean, | ||
@SerialName("name") | ||
val name: String?, | ||
@SerialName("phone") | ||
val phone: String | ||
) |
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
14 changes: 11 additions & 3 deletions
14
data/auth/src/main/java/org/sopt/official/data/auth/repository/DefaultAuthRepository.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,15 +1,23 @@ | ||
package org.sopt.official.data.auth.repository | ||
|
||
import org.sopt.official.data.auth.mapper.toDomain | ||
import org.sopt.official.data.auth.mapper.toRequest | ||
import org.sopt.official.data.auth.remote.api.AuthApi | ||
import org.sopt.official.domain.auth.model.UserInformation | ||
import org.sopt.official.domain.auth.model.InformationWithCode | ||
import org.sopt.official.domain.auth.model.InitialInformation | ||
import org.sopt.official.domain.auth.model.VerificationResult | ||
import org.sopt.official.domain.auth.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
internal class DefaultAuthRepository @Inject constructor( | ||
private val authApi: AuthApi | ||
) : AuthRepository { | ||
override suspend fun getCertificationNumber(request: UserInformation): Result<Unit> = runCatching { | ||
authApi.postCertificationNumber(request.toRequest()) | ||
override suspend fun createCode(request: InitialInformation): Result<Unit> = runCatching { | ||
authApi.createCode(request.toRequest()) | ||
} | ||
|
||
override suspend fun certificateCode(request: InformationWithCode): Result<VerificationResult> = | ||
runCatching { | ||
authApi.certificateCode(request.toRequest()).data.toDomain() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
domain/auth/src/main/java/org/sopt/official/domain/auth/model/InformationWithCode.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,8 @@ | ||
package org.sopt.official.domain.auth.model | ||
|
||
data class InformationWithCode( | ||
val name: String?, | ||
val phone: String, | ||
val code: String, | ||
val type: String | ||
) |
2 changes: 1 addition & 1 deletion
2
...cial/domain/auth/model/UserInformation.kt → ...l/domain/auth/model/InitialInformation.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
7 changes: 7 additions & 0 deletions
7
domain/auth/src/main/java/org/sopt/official/domain/auth/model/VerificationResult.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,7 @@ | ||
package org.sopt.official.domain.auth.model | ||
|
||
data class VerificationResult( | ||
val isVerified: Boolean, | ||
val name: String?, | ||
val phone: String | ||
) |
8 changes: 6 additions & 2 deletions
8
domain/auth/src/main/java/org/sopt/official/domain/auth/repository/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,7 +1,11 @@ | ||
package org.sopt.official.domain.auth.repository | ||
|
||
import org.sopt.official.domain.auth.model.UserInformation | ||
import org.sopt.official.domain.auth.model.InformationWithCode | ||
import org.sopt.official.domain.auth.model.InitialInformation | ||
import org.sopt.official.domain.auth.model.VerificationResult | ||
|
||
interface AuthRepository { | ||
suspend fun getCertificationNumber(request: UserInformation) : Result<Unit> | ||
suspend fun createCode(request: InitialInformation): Result<Unit> | ||
|
||
suspend fun certificateCode(request: InformationWithCode): Result<VerificationResult> | ||
} |