generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #168 from GSM-MSG/feature/#167_email_domain_networ…
…k_setting 🔀 :: (#167) Email Domain Network Setting
- Loading branch information
Showing
11 changed files
with
143 additions
and
0 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
10 changes: 10 additions & 0 deletions
10
core/data/src/main/java/com/msg/data/repository/email/EmailRepository.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,10 @@ | ||
package com.msg.data.repository.email | ||
|
||
import com.msg.model.remote.request.email.SendLinkToEmailRequest | ||
import com.msg.model.remote.response.email.GetEmailAuthenticateStatusResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface EmailRepository { | ||
suspend fun sendLinkToEmail(body: SendLinkToEmailRequest): Flow<Unit> | ||
suspend fun getEmailAuthenticateStatus(email: String): Flow<GetEmailAuthenticateStatusResponse> | ||
} |
23 changes: 23 additions & 0 deletions
23
core/data/src/main/java/com/msg/data/repository/email/EmailRepositoryImpl.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,23 @@ | ||
package com.msg.data.repository.email | ||
|
||
import com.msg.model.remote.request.email.SendLinkToEmailRequest | ||
import com.msg.model.remote.response.email.GetEmailAuthenticateStatusResponse | ||
import com.msg.network.datasource.email.EmailDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class EmailRepositoryImpl @Inject constructor( | ||
private val emailDataSource: EmailDataSource | ||
) : EmailRepository { | ||
override suspend fun sendLinkToEmail(body: SendLinkToEmailRequest): Flow<Unit> { | ||
return emailDataSource.sendLinkToEmail( | ||
body = body | ||
) | ||
} | ||
|
||
override suspend fun getEmailAuthenticateStatus(email: String): Flow<GetEmailAuthenticateStatusResponse> { | ||
return emailDataSource.getEmailAuthenticateStatus( | ||
email = email | ||
) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
core/domain/src/main/java/com/msg/domain/email/GetEmailAuthenticateStatusUseCase.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,12 @@ | ||
package com.msg.domain.email | ||
|
||
import com.msg.data.repository.email.EmailRepository | ||
import javax.inject.Inject | ||
|
||
class GetEmailAuthenticateStatusUseCase @Inject constructor( | ||
private val emailRepository: EmailRepository | ||
) { | ||
suspend operator fun invoke(email: String) = runCatching { | ||
emailRepository.getEmailAuthenticateStatus(email = email) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/msg/domain/email/SendLinkToEmailUseCase.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 com.msg.domain.email | ||
|
||
import com.msg.data.repository.email.EmailRepository | ||
import com.msg.model.remote.request.email.SendLinkToEmailRequest | ||
import javax.inject.Inject | ||
|
||
class SendLinkToEmailUseCase @Inject constructor( | ||
private val emailRepository: EmailRepository | ||
) { | ||
suspend operator fun invoke(body: SendLinkToEmailRequest) = runCatching { | ||
emailRepository.sendLinkToEmail(body = body) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
core/model/src/main/java/com/msg/model/remote/request/email/SendLinkToEmailRequest.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.msg.model.remote.request.email | ||
|
||
data class SendLinkToEmailRequest( | ||
val email: String, | ||
) |
5 changes: 5 additions & 0 deletions
5
...l/src/main/java/com/msg/model/remote/response/email/GetEmailAuthenticateStatusResponse.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.msg.model.remote.response.email | ||
|
||
data class GetEmailAuthenticateStatusResponse( | ||
val isAuthentication: Boolean, | ||
) |
20 changes: 20 additions & 0 deletions
20
core/network/src/main/java/com/msg/network/api/EmailAPI.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,20 @@ | ||
package com.msg.network.api | ||
|
||
import com.msg.model.remote.request.email.SendLinkToEmailRequest | ||
import com.msg.model.remote.response.email.GetEmailAuthenticateStatusResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Query | ||
|
||
interface EmailAPI { | ||
@POST("email") | ||
suspend fun sendLinkToEmail( | ||
@Body body: SendLinkToEmailRequest | ||
) | ||
|
||
@GET("email") | ||
suspend fun getEmailAuthenticateStatus( | ||
@Query("email") email: String | ||
): GetEmailAuthenticateStatusResponse | ||
} |
10 changes: 10 additions & 0 deletions
10
core/network/src/main/java/com/msg/network/datasource/email/EmailDataSource.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,10 @@ | ||
package com.msg.network.datasource.email | ||
|
||
import com.msg.model.remote.request.email.SendLinkToEmailRequest | ||
import com.msg.model.remote.response.email.GetEmailAuthenticateStatusResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface EmailDataSource { | ||
suspend fun sendLinkToEmail(body: SendLinkToEmailRequest): Flow<Unit> | ||
suspend fun getEmailAuthenticateStatus(email: String): Flow<GetEmailAuthenticateStatusResponse> | ||
} |
31 changes: 31 additions & 0 deletions
31
core/network/src/main/java/com/msg/network/datasource/email/EmailDataSourceImpl.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,31 @@ | ||
package com.msg.network.datasource.email | ||
|
||
import com.msg.model.remote.request.email.SendLinkToEmailRequest | ||
import com.msg.model.remote.response.email.GetEmailAuthenticateStatusResponse | ||
import com.msg.network.api.EmailAPI | ||
import com.msg.network.util.BitgoeulApiHandler | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOn | ||
import javax.inject.Inject | ||
|
||
class EmailDataSourceImpl @Inject constructor( | ||
private val emailAPI: EmailAPI | ||
) : EmailDataSource { | ||
override suspend fun sendLinkToEmail(body: SendLinkToEmailRequest): Flow<Unit> = flow { | ||
emit( | ||
BitgoeulApiHandler<Unit>() | ||
.httpRequest { emailAPI.sendLinkToEmail(body = body) } | ||
.sendRequest() | ||
) | ||
}.flowOn(Dispatchers.IO) | ||
|
||
override suspend fun getEmailAuthenticateStatus(email: String): Flow<GetEmailAuthenticateStatusResponse> = flow { | ||
emit( | ||
BitgoeulApiHandler<GetEmailAuthenticateStatusResponse>() | ||
.httpRequest { emailAPI.getEmailAuthenticateStatus(email = email) } | ||
.sendRequest() | ||
) | ||
}.flowOn(Dispatchers.IO) | ||
} |
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