From 4fdeef77556b9d43cf947e93bd4b23d8442c2172 Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 09:47:22 +0900 Subject: [PATCH 1/7] =?UTF-8?q?:sparkles:=20::=20EmailAPI=20interface=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit new --- .../request/email/SendLinkToEmailRequest.kt | 5 +++++ .../GetEmailAuthenticateStatusResponse.kt | 5 +++++ .../main/java/com/msg/network/api/EmailAPI.kt | 20 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 core/model/src/main/java/com/msg/model/remote/request/email/SendLinkToEmailRequest.kt create mode 100644 core/model/src/main/java/com/msg/model/remote/response/email/GetEmailAuthenticateStatusResponse.kt create mode 100644 core/network/src/main/java/com/msg/network/api/EmailAPI.kt diff --git a/core/model/src/main/java/com/msg/model/remote/request/email/SendLinkToEmailRequest.kt b/core/model/src/main/java/com/msg/model/remote/request/email/SendLinkToEmailRequest.kt new file mode 100644 index 00000000..fb31cb54 --- /dev/null +++ b/core/model/src/main/java/com/msg/model/remote/request/email/SendLinkToEmailRequest.kt @@ -0,0 +1,5 @@ +package com.msg.model.remote.request.email + +data class SendLinkToEmailRequest( + val email: String, +) diff --git a/core/model/src/main/java/com/msg/model/remote/response/email/GetEmailAuthenticateStatusResponse.kt b/core/model/src/main/java/com/msg/model/remote/response/email/GetEmailAuthenticateStatusResponse.kt new file mode 100644 index 00000000..4467022b --- /dev/null +++ b/core/model/src/main/java/com/msg/model/remote/response/email/GetEmailAuthenticateStatusResponse.kt @@ -0,0 +1,5 @@ +package com.msg.model.remote.response.email + +data class GetEmailAuthenticateStatusResponse( + val isAuthentication: Boolean, +) diff --git a/core/network/src/main/java/com/msg/network/api/EmailAPI.kt b/core/network/src/main/java/com/msg/network/api/EmailAPI.kt new file mode 100644 index 00000000..717ffc0c --- /dev/null +++ b/core/network/src/main/java/com/msg/network/api/EmailAPI.kt @@ -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 +} \ No newline at end of file From 143a89e435d535c2a5bc169635b33d979f71b899 Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 09:52:43 +0900 Subject: [PATCH 2/7] =?UTF-8?q?:sparkles:=20::=20EmailDataSource=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :: EmailDataSource 작성 --- .../datasource/email/EmailDataSource.kt | 10 ++++++ .../datasource/email/EmailDataSourceImpl.kt | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 core/network/src/main/java/com/msg/network/datasource/email/EmailDataSource.kt create mode 100644 core/network/src/main/java/com/msg/network/datasource/email/EmailDataSourceImpl.kt diff --git a/core/network/src/main/java/com/msg/network/datasource/email/EmailDataSource.kt b/core/network/src/main/java/com/msg/network/datasource/email/EmailDataSource.kt new file mode 100644 index 00000000..49b282b2 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/email/EmailDataSource.kt @@ -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 + suspend fun getEmailAuthenticateStatus(email: String): Flow +} \ No newline at end of file diff --git a/core/network/src/main/java/com/msg/network/datasource/email/EmailDataSourceImpl.kt b/core/network/src/main/java/com/msg/network/datasource/email/EmailDataSourceImpl.kt new file mode 100644 index 00000000..082ffd61 --- /dev/null +++ b/core/network/src/main/java/com/msg/network/datasource/email/EmailDataSourceImpl.kt @@ -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 = flow { + emit( + BitgoeulApiHandler() + .httpRequest { emailAPI.sendLinkToEmail(body = body) } + .sendRequest() + ) + }.flowOn(Dispatchers.IO) + + override suspend fun getEmailAuthenticateStatus(email: String): Flow = flow { + emit( + BitgoeulApiHandler() + .httpRequest { emailAPI.getEmailAuthenticateStatus(email = email) } + .sendRequest() + ) + }.flowOn(Dispatchers.IO) +} \ No newline at end of file From ed07fb85b01ffb9c095da9df75203ece27c343d9 Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 09:57:36 +0900 Subject: [PATCH 3/7] =?UTF-8?q?:sparkles:=20::=20EmailRepository=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :: EmailRepository 작성 --- .../data/repository/email/EmailRepository.kt | 10 ++++++++ .../repository/email/EmailRepositoryImpl.kt | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 core/data/src/main/java/com/msg/data/repository/email/EmailRepository.kt create mode 100644 core/data/src/main/java/com/msg/data/repository/email/EmailRepositoryImpl.kt diff --git a/core/data/src/main/java/com/msg/data/repository/email/EmailRepository.kt b/core/data/src/main/java/com/msg/data/repository/email/EmailRepository.kt new file mode 100644 index 00000000..da7192a5 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/email/EmailRepository.kt @@ -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 + suspend fun getEmailAuthenticateStatus(email: String): Flow +} \ No newline at end of file diff --git a/core/data/src/main/java/com/msg/data/repository/email/EmailRepositoryImpl.kt b/core/data/src/main/java/com/msg/data/repository/email/EmailRepositoryImpl.kt new file mode 100644 index 00000000..0b6459e9 --- /dev/null +++ b/core/data/src/main/java/com/msg/data/repository/email/EmailRepositoryImpl.kt @@ -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 { + return emailDataSource.sendLinkToEmail( + body = body + ) + } + + override suspend fun getEmailAuthenticateStatus(email: String): Flow { + return emailDataSource.getEmailAuthenticateStatus( + email = email + ) + } +} \ No newline at end of file From 10c867372550ad54ad5990717170af80c87caf6b Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 09:58:18 +0900 Subject: [PATCH 4/7] :sparkles: :: EmailRepository Bind :: EmailRepository Bind --- .../data/src/main/java/com/msg/data/di/RepositoryModule.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt b/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt index badef000..4d9fc04d 100644 --- a/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt +++ b/core/data/src/main/java/com/msg/data/di/RepositoryModule.kt @@ -10,6 +10,8 @@ import com.msg.data.repository.certification.CertificationRepository import com.msg.data.repository.certification.CertificationRepositoryImpl import com.msg.data.repository.club.ClubRepository import com.msg.data.repository.club.ClubRepositoryImpl +import com.msg.data.repository.email.EmailRepository +import com.msg.data.repository.email.EmailRepositoryImpl import com.msg.data.repository.faq.FaqRepository import com.msg.data.repository.faq.FaqRepositoryImpl import com.msg.data.repository.lecture.LectureRepository @@ -70,4 +72,9 @@ abstract class RepositoryModule { abstract fun bindPostRepository( postRepositoryImpl: PostRepositoryImpl ): PostRepository + + @Binds + abstract fun bindEmailRepository( + emailRepositoryImpl: EmailRepositoryImpl + ): EmailRepository } \ No newline at end of file From b9b5846072bac58ff95d2c11834a2fdc933acb1e Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 09:58:56 +0900 Subject: [PATCH 5/7] :sparkles: :: EmailDataSource Bind :: EmailDataSource Bind --- .../src/main/java/com/msg/network/di/DataSourceModule.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/network/src/main/java/com/msg/network/di/DataSourceModule.kt b/core/network/src/main/java/com/msg/network/di/DataSourceModule.kt index 1a47c23b..887a4556 100644 --- a/core/network/src/main/java/com/msg/network/di/DataSourceModule.kt +++ b/core/network/src/main/java/com/msg/network/di/DataSourceModule.kt @@ -10,6 +10,8 @@ import com.msg.network.datasource.certification.CertificationDataSource import com.msg.network.datasource.certification.CertificationDataSourceImpl import com.msg.network.datasource.club.ClubDataSource import com.msg.network.datasource.club.ClubDataSourceImpl +import com.msg.network.datasource.email.EmailDataSource +import com.msg.network.datasource.email.EmailDataSourceImpl import com.msg.network.datasource.faq.FaqDataSource import com.msg.network.datasource.faq.FaqDataSourceImpl import com.msg.network.datasource.lecture.LectureDataSource @@ -70,4 +72,9 @@ abstract class DataSourceModule { abstract fun bindPostDataSource( postDataSourceImpl: PostDataSourceImpl ): PostDataSource + + @Binds + abstract fun bindEmailDataSource( + emailDataSourceImpl: EmailDataSourceImpl + ): EmailDataSource } \ No newline at end of file From 91e96e3bbbdabaccb18942f50149cf90b6318921 Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 10:00:50 +0900 Subject: [PATCH 6/7] =?UTF-8?q?:sparkles:=20::=20SendLinkEmailUseCase=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :: SendLinkEmailUseCase 작성 --- .../com/msg/domain/email/SendLinkToEmailUseCase.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 core/domain/src/main/java/com/msg/domain/email/SendLinkToEmailUseCase.kt diff --git a/core/domain/src/main/java/com/msg/domain/email/SendLinkToEmailUseCase.kt b/core/domain/src/main/java/com/msg/domain/email/SendLinkToEmailUseCase.kt new file mode 100644 index 00000000..4d2a75b1 --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/email/SendLinkToEmailUseCase.kt @@ -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) + } +} From 2bc0a4d6d67fdb0bfab232a1d50781f0733a20ce Mon Sep 17 00:00:00 2001 From: Chaejongin12 Date: Fri, 26 Apr 2024 10:01:47 +0900 Subject: [PATCH 7/7] :sparkles: :: GetEmailAuthenticateStatusUseCase wkrtjd :: GetEmailAuthenticateStatusUseCase wkrtjd --- .../email/GetEmailAuthenticateStatusUseCase.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 core/domain/src/main/java/com/msg/domain/email/GetEmailAuthenticateStatusUseCase.kt diff --git a/core/domain/src/main/java/com/msg/domain/email/GetEmailAuthenticateStatusUseCase.kt b/core/domain/src/main/java/com/msg/domain/email/GetEmailAuthenticateStatusUseCase.kt new file mode 100644 index 00000000..8bfa36aa --- /dev/null +++ b/core/domain/src/main/java/com/msg/domain/email/GetEmailAuthenticateStatusUseCase.kt @@ -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) + } +} \ No newline at end of file