-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [chore] hilt 의존성 추가 * [feature] PokitApplication 구현 및 등록 * [feature] NetworkModule 모듈 구현 * [chore] 타임아웃 설정 * [chore] auth request, response 데이터 추가 * [chore] auth api 추가 * [chore] auth api 수정 * [chore] 버전 카탈로그 라이브러리 추가 - domain 모듈 inject - logging-interceptor * [feature] hilt + 네트워크 모듈 구현 * [chore] @androidentrypoint 애노테이션 추가 * [chore] kotest 의존성 추가 * [feature] sns로그인 api연동 * [feature] 테스트 토큰 인터셉터 구현 * [feature] 닉네임 입력 화면 설계 * [chore] 뷰모델 주입 * [chore] 미사용 리소스 제거 * [chore] 코딩 컨벤션 적용 * [chore] 코딩 컨벤션 적용 * [chore] orbit 제거 * [chore] LoginScreen 로직 수정 * [feature] 애플 로그인 구현 * [feature] 네트워크 통신 모듈 구현 * [chore] 클래스명 수정 * [chore] 주석 제거 * [feature] parseErrorResult 함수 구현 * [chore] 닉네임 중복 처리 api 세팅 * [chore] parseErrorResult 분리 및 적용 * [chore] 중복 닉네임 api 세팅 * [chore] 코딩 컨벤션 반영 * [chore] ktlint rule 추가 * [chore] ktlint_standard_function-name 제거 * [chore] 파일 이름 수정
- Loading branch information
Showing
44 changed files
with
716 additions
and
64 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
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,62 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "217769178527", | ||
"project_id": "pokit-f5c83", | ||
"storage_bucket": "pokit-f5c83.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:217769178527:android:5d7efa4ceafe61c37af9aa", | ||
"android_client_info": { | ||
"package_name": "pokitmons.pokit" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "217769178527-jaa8p8nfmic1j1065qs5a7vfqt18qec0.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "pokitmons.pokit", | ||
"certificate_hash": "9ded6dcd446add68f506001f3c1b457cc1c3be9e" | ||
} | ||
}, | ||
{ | ||
"client_id": "217769178527-mmbheg9v5npdhdrbfq78slpsk8lt2nga.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "pokitmons.pokit", | ||
"certificate_hash": "b2f3e34f8e02d15beb0d10d3d48a05148e943642" | ||
} | ||
}, | ||
{ | ||
"client_id": "217769178527-tslgsrrr1o8bli4hr4qnas2u9kg80a9h.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyDMh93QvJGUUX8-E-wyJoSS3cFrwfw8Q3w" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "217769178527-l4prj2q9qsuvkodc2cpi84psvul5rth2.apps.googleusercontent.com", | ||
"client_type": 3 | ||
}, | ||
{ | ||
"client_id": "217769178527-021j3dpbues9rhbkp6cffnn19mdajorq.apps.googleusercontent.com", | ||
"client_type": 2, | ||
"ios_info": { | ||
"bundle_id": "com.pokitmons.pokit.App" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
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
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 pokitmons.pokit | ||
|
||
import android.app.Application | ||
import com.google.firebase.FirebaseApp | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class PokitApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
FirebaseApp.initializeApp(this) | ||
} | ||
} |
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
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 pokitmons.pokit.data.api | ||
|
||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.data.model.auth.response.DuplicateNicknameResponse | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface AuthApi { | ||
@POST("auth/signin") | ||
suspend fun snsLogin( | ||
@Body snsLoginRequest: SNSLoginRequest, | ||
): SNSLoginResponse | ||
|
||
@GET("user/duplicate/{nickname}") | ||
suspend fun checkDuplicateNickname( | ||
@Path(value = "nickname") nickname: String, | ||
): DuplicateNicknameResponse | ||
} |
11 changes: 11 additions & 0 deletions
11
data/src/main/java/pokitmons/pokit/data/datasource/remote/auth/AuthDataSource.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 pokitmons.pokit.data.datasource.remote.auth | ||
|
||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.data.model.auth.response.DuplicateNicknameResponse | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
|
||
interface AuthDataSource { | ||
// suspend fun signUp(signUpRequest: SignUpRequest): PokitResponse<SignUpResponse> | ||
suspend fun snsLogin(snsLoginRequest: SNSLoginRequest): SNSLoginResponse | ||
suspend fun checkDuplicateNickname(nickname: String): DuplicateNicknameResponse | ||
} |
17 changes: 17 additions & 0 deletions
17
data/src/main/java/pokitmons/pokit/data/datasource/remote/auth/RemoteAuthDataSourceImpl.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,17 @@ | ||
package pokitmons.pokit.data.datasource.remote.auth | ||
|
||
import pokitmons.pokit.data.api.AuthApi | ||
import pokitmons.pokit.data.model.auth.request.SNSLoginRequest | ||
import pokitmons.pokit.data.model.auth.response.DuplicateNicknameResponse | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
import javax.inject.Inject | ||
|
||
class RemoteAuthDataSourceImpl @Inject constructor(private val authApi: AuthApi) : AuthDataSource { | ||
override suspend fun snsLogin(snsLoginRequest: SNSLoginRequest): SNSLoginResponse { | ||
return authApi.snsLogin(snsLoginRequest) | ||
} | ||
|
||
override suspend fun checkDuplicateNickname(nickname: String): DuplicateNicknameResponse { | ||
return authApi.checkDuplicateNickname(nickname) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
data/src/main/java/pokitmons/pokit/data/di/auth/AuthModule.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 pokitmons.pokit.data.di.auth | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import pokitmons.pokit.data.datasource.remote.auth.AuthDataSource | ||
import pokitmons.pokit.data.datasource.remote.auth.RemoteAuthDataSourceImpl | ||
import pokitmons.pokit.data.repository.auth.AuthRepositoryImpl | ||
import pokitmons.pokit.domain.repository.auth.AuthRepository | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class AuthModule { | ||
@Binds | ||
@Singleton | ||
abstract fun bindAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository | ||
|
||
@Binds | ||
@Singleton | ||
abstract fun bindAuthDataSource(authDataSourceImpl: RemoteAuthDataSourceImpl): AuthDataSource | ||
} |
23 changes: 23 additions & 0 deletions
23
data/src/main/java/pokitmons/pokit/data/di/network/BearerTokenInterceptor.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 pokitmons.pokit.data.di.network | ||
|
||
import okhttp3.Interceptor | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import java.io.IOException | ||
|
||
// 토큰 api 수정될 때 까지 사용 | ||
class BearerTokenInterceptor : Interceptor { | ||
@Throws(IOException::class) | ||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val originalRequest: Request = chain.request() | ||
val requestWithToken: Request = originalRequest.newBuilder() | ||
.header( | ||
"Authorization", | ||
"Bearer eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzIxNjU4MjUxLCJleHAiOj" + | ||
"MwMDE3MjE2NTgyNTF9.gw6LZimKLuZJ2y0UV5cgvk3F7o92pkRIDgx-qlD_S7qEI01QAFt9dZDyHADabftI" | ||
) | ||
.build() | ||
|
||
return chain.proceed(requestWithToken) | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
data/src/main/java/pokitmons/pokit/data/di/network/NetworkModule.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,70 @@ | ||
package pokitmons.pokit.data.di.network | ||
|
||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import pokitmons.pokit.data.api.AuthApi | ||
import retrofit2.Retrofit | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Singleton | ||
|
||
private const val BASE_URL = "https://pokit.site" | ||
private const val API = "api" | ||
private const val VERSION = "v1" | ||
|
||
private const val READ_TIME_OUT = 20000L | ||
private const val WRITE_TIME_OUT = 20000L | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object NetworkModule { | ||
@Singleton | ||
@Provides | ||
fun provideOkHttpClient(): OkHttpClient { | ||
return OkHttpClient.Builder() | ||
.addInterceptor(BearerTokenInterceptor()) | ||
.addInterceptor( | ||
HttpLoggingInterceptor().apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
) | ||
.readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) | ||
.writeTimeout(WRITE_TIME_OUT, TimeUnit.SECONDS) | ||
.build() | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideJson(): Json { | ||
return Json { | ||
ignoreUnknownKeys = true | ||
coerceInputValues = true | ||
prettyPrint = true | ||
} | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideRetrofit( | ||
okHttpClient: OkHttpClient, | ||
json: Json, | ||
): Retrofit { | ||
val converterFactory = json.asConverterFactory("application/json; charset=UTF8".toMediaType()) | ||
return Retrofit.Builder() | ||
.baseUrl("$BASE_URL/$API/$VERSION/") | ||
.addConverterFactory(converterFactory) | ||
.client(okHttpClient) | ||
.build() | ||
} | ||
|
||
@Provides | ||
fun provideAuthService(retrofit: Retrofit): AuthApi { | ||
return retrofit.create(AuthApi::class.java) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
data/src/main/java/pokitmons/pokit/data/mapper/auth/AuthMapper.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 pokitmons.pokit.data.mapper.auth | ||
|
||
import pokitmons.pokit.data.model.auth.response.DuplicateNicknameResponse | ||
import pokitmons.pokit.data.model.auth.response.SNSLoginResponse | ||
import pokitmons.pokit.domain.model.auth.DuplicateNicknameResult | ||
import pokitmons.pokit.domain.model.auth.SNSLoginResult | ||
|
||
object AuthMapper { | ||
fun mapperToSNSLogin(snsLoginResponse: SNSLoginResponse): SNSLoginResult { | ||
return SNSLoginResult( | ||
accessToken = snsLoginResponse.accessToken, | ||
refreshToken = snsLoginResponse.refreshToken | ||
) | ||
} | ||
|
||
fun mapperToDuplicateNickname(checkDuplicateNicknameResponse: DuplicateNicknameResponse): DuplicateNicknameResult { | ||
return DuplicateNicknameResult( | ||
isDuplicate = checkDuplicateNicknameResponse.isDuplicate | ||
) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
data/src/main/java/pokitmons/pokit/data/model/auth/request/SNSLoginRequest.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,9 @@ | ||
package pokitmons.pokit.data.model.auth.request | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SNSLoginRequest( | ||
val authPlatform: String, | ||
val idToken: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
data/src/main/java/pokitmons/pokit/data/model/auth/request/SignUpRequest.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,6 @@ | ||
package pokitmons.pokit.data.model.auth.request | ||
|
||
data class SignUpRequest( | ||
val nickname: String, | ||
val interests: List<String>, | ||
) |
Oops, something went wrong.