diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt index c764c157..5b4489ed 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/AuthDataSourceImpl.kt @@ -10,19 +10,15 @@ import javax.inject.Inject class AuthDataSourceImpl @Inject constructor( private val firebaseAuth: FirebaseAuth, ) : AuthDataSource { - override suspend fun signOut(): Result { - return runCatching { - firebaseAuth.signOut() - } + override suspend fun signOut(): Result = runCatching { + firebaseAuth.signOut() } - override suspend fun deleteUser(): Result { - return runCatching { - val user = checkNotNull(firebaseAuth.currentUser) + override suspend fun deleteUser(): Result = runCatching { + val user = checkNotNull(firebaseAuth.currentUser) - user.delete() - .await() - } + user.delete() + .await() } @OptIn(ExperimentalCoroutinesApi::class) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignInDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignInDataSourceImpl.kt index 15fe51fc..e5ae18f7 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignInDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignInDataSourceImpl.kt @@ -12,19 +12,18 @@ class SignInDataSourceImpl @Inject constructor( private val firebaseAuth: FirebaseAuth, @ActivityContext private val context: Context, ) : SignInDataSource { - override suspend fun signIn(email: String): Result = - runCatching { - val provider = OAuthProvider.newBuilder("github.com") - provider.addCustomParameter("login", email) + override suspend fun signIn(email: String): Result = runCatching { + val provider = OAuthProvider.newBuilder("github.com") + provider.addCustomParameter("login", email) - val activityContext = context as Activity + val activityContext = context as Activity - val result = firebaseAuth.startActivityForSignInWithProvider( - activityContext, - provider.build(), - ).await() + val result = firebaseAuth.startActivityForSignInWithProvider( + activityContext, + provider.build(), + ).await() - val user = checkNotNull(result.user) - user.uid - } + val user = checkNotNull(result.user) + user.uid + } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt index adbd9dde..3e3ef25b 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/event/EventDataSourceImpl.kt @@ -102,15 +102,14 @@ class EventDataSourceImpl @Inject constructor( result } - override suspend fun getEvent(eventId: String): Result = - runCatching { - val document = firebaseFirestore.collection(EVENT_COLLECTION) - .document(eventId) - .get() - .await() + override suspend fun getEvent(eventId: String): Result = runCatching { + val document = firebaseFirestore.collection(EVENT_COLLECTION) + .document(eventId) + .get() + .await() - checkNotNull(document.toObject()) - } + checkNotNull(document.toObject()) + } override suspend fun deleteEvent(eventId: String): Result = runCatching { firebaseFirestore.collection(EVENT_COLLECTION) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt index a0962beb..8cb01873 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyDataSourceImpl.kt @@ -48,26 +48,26 @@ class SurveyDataSourceImpl @Inject constructor( result } - override suspend fun getSurveyListBySurveyFormId(surveyFormId: String) - : Result> = - runCatching { - val result: MutableList = mutableListOf() - - val task = firebaseFirestore.collection(SURVEY_COLLECTION) - .whereEqualTo("surveyFormId", surveyFormId) - .get() - .await() + override suspend fun getSurveyListBySurveyFormId( + surveyFormId: String, + ): Result> = runCatching { + val result: MutableList = mutableListOf() - for (document in task.documents) { - val surveyResponse = document.toObject(SurveyResponse::class.java) - checkNotNull(surveyResponse) + val task = firebaseFirestore.collection(SURVEY_COLLECTION) + .whereEqualTo("surveyFormId", surveyFormId) + .get() + .await() - result.add(surveyResponse) - } + for (document in task.documents) { + val surveyResponse = document.toObject(SurveyResponse::class.java) + checkNotNull(surveyResponse) - result + result.add(surveyResponse) } + result + } + override suspend fun getUserRespondedSurveyList(userId: String): Result> = runCatching { val result: MutableList = mutableListOf() diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt index 6d29dd84..ca72a45b 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/survey/SurveyFormDataSourceImpl.kt @@ -42,25 +42,24 @@ class SurveyFormDataSourceImpl @Inject constructor( override suspend fun getSurveyFormListByEventId( eventId: String, - ): Result> = - runCatching { - val result: MutableList = mutableListOf() - - val task = firebaseFirestore.collection(SURVEY_FORM_COLLECTION) - .whereEqualTo("eventId", eventId) - .get() - .await() + ): Result> = runCatching { + val result: MutableList = mutableListOf() - for (document in task.documents) { - val surveyFormResponse = document.toObject(SurveyFormResponse::class.java) - checkNotNull(surveyFormResponse) + val task = firebaseFirestore.collection(SURVEY_FORM_COLLECTION) + .whereEqualTo("eventId", eventId) + .get() + .await() - result.add(surveyFormResponse) - } + for (document in task.documents) { + val surveyFormResponse = document.toObject(SurveyFormResponse::class.java) + checkNotNull(surveyFormResponse) - result + result.add(surveyFormResponse) } + result + } + override suspend fun deleteSurveyForm(surveyFormId: String): Result = runCatching { firebaseFirestore.collection(SURVEY_FORM_COLLECTION) .document(surveyFormId) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt index d4f06c72..88e0e60c 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/user/UserDataSourceImpl.kt @@ -15,39 +15,33 @@ class UserDataSourceImpl @Inject constructor( ) : UserDataSource { override suspend fun postUserProfile( userProfileRequest: UserProfileRequest, - ): Result { - return runCatching { - val userId = userProfileRequest.userId - val setOption = SetOptions.merge() + ): Result = runCatching { + val userId = userProfileRequest.userId + val setOption = SetOptions.merge() - firebaseFirestore.collection(USER_COLLECTION) - .document(userId) - .set( - userProfileRequest, - setOption, - ) - .await() - } + firebaseFirestore.collection(USER_COLLECTION) + .document(userId) + .set( + userProfileRequest, + setOption, + ) + .await() } - override suspend fun getUserId(): Result { - return runCatching { - checkNotNull(firebaseAuth.uid) - } + override suspend fun getUserId(): Result = runCatching { + checkNotNull(firebaseAuth.uid) } override suspend fun getUserProfile( userId: String, - ): Result { - return runCatching { - val result = firebaseFirestore.collection(USER_COLLECTION) - .document(userId) - .get() - .await() + ): Result = runCatching { + val result = firebaseFirestore.collection(USER_COLLECTION) + .document(userId) + .get() + .await() - val userProfile = result.toObject(UserProfileResponse::class.java) - checkNotNull(userProfile) - } + val userProfile = result.toObject(UserProfileResponse::class.java) + checkNotNull(userProfile) } override suspend fun deleteUserProfile(userId: String): Result = runCatching {