From 74409d902fdbfe0e8868d7de605cd47f8896e5e0 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Wed, 28 Feb 2024 01:56:03 +0900 Subject: [PATCH] [FEATURE] #141 : SignUpDataSource --- .../network/source/auth/SignUpDataSource.kt | 5 +++++ .../source/auth/SignUpDataSourceImpl.kt | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt new file mode 100644 index 00000000..b0e6a71e --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSource.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.network.source.auth + +interface SignUpDataSource { + suspend fun validationWapCode(code: String): Result +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt new file mode 100644 index 00000000..eb32fa1b --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/auth/SignUpDataSourceImpl.kt @@ -0,0 +1,19 @@ +package com.wap.wapp.core.network.source.auth + +import com.google.firebase.firestore.FirebaseFirestore +import com.wap.wapp.core.network.constant.CODES_COLLECTION +import com.wap.wapp.core.network.utils.await +import javax.inject.Inject + +class SignUpDataSourceImpl @Inject constructor( + private val firebaseFirestore: FirebaseFirestore, +) : SignUpDataSource { + override suspend fun validationWapCode(code: String): Result = runCatching { + val result = firebaseFirestore.collection(CODES_COLLECTION) + .whereEqualTo("user", code) + .get() + .await() + + result.isEmpty.not() + } +}