Skip to content

feature: 코스 퀘스트 API 추가사항 구현 #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.kt]
ktlint_standard_function-naming = disabled
ktlint_standard_modifier-order = disabled
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import com.teamoffroad.app.configureHiltAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project

class AndroidHiltConventionPlugin : Plugin<Project> {

class AndroidHiltConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
configureHiltAndroid()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import org.gradle.api.Plugin
import org.gradle.api.Project

class KotlinHiltConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
configureHiltKotlin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {

private const val BASE_URL = BuildConfig.BASE_URL
private const val CONTENT_TYPE = "application/json"

private val json: Json = Json {
ignoreUnknownKeys = true
}
private val json: Json =
Json {
ignoreUnknownKeys = true
}

@Provides
@Singleton
fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor {
val loggingInterceptor = HttpLoggingInterceptor { message ->
Log.d("Retrofit2", "CONNECTION INFO -> $message")
}
val loggingInterceptor =
HttpLoggingInterceptor { message ->
Log.d("Retrofit2", "CONNECTION INFO -> $message")
}
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
return loggingInterceptor
}
Expand All @@ -46,55 +47,57 @@ object NetworkModule {
fun provideOkHttpClient(
loggingInterceptor: HttpLoggingInterceptor,
authInterceptor: AuthInterceptor,
): OkHttpClient {
return OkHttpClient.Builder()
): OkHttpClient =
OkHttpClient
.Builder()
.addInterceptor(loggingInterceptor)
.addInterceptor(authInterceptor)
.build()
}

@Provides
@Singleton
@NoneAuth
fun provideNoneAuthOkHttpClient(
loggingInterceptor: HttpLoggingInterceptor,
): OkHttpClient {
return OkHttpClient.Builder()
fun provideNoneAuthOkHttpClient(loggingInterceptor: HttpLoggingInterceptor): OkHttpClient =
OkHttpClient
.Builder()
.addInterceptor(loggingInterceptor)
.build()
}

@Provides
@Singleton
@Auth
fun provideRetrofit(@Auth okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
fun provideRetrofit(
@Auth okHttpClient: OkHttpClient,
): Retrofit =
Retrofit
.Builder()
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(json.asConverterFactory(CONTENT_TYPE.toMediaType()))
.build()
}

@Provides
@Singleton
@NoneAuth
fun provideNoneAuthRetrofit(@NoneAuth okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
fun provideNoneAuthRetrofit(
@NoneAuth okHttpClient: OkHttpClient,
): Retrofit =
Retrofit
.Builder()
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(json.asConverterFactory(CONTENT_TYPE.toMediaType()))
.build()
}

@Provides
@Singleton
fun provideTokenService(@NoneAuth retrofit: Retrofit): TokenService {
return retrofit.create(TokenService::class.java)
}
fun provideTokenService(
@NoneAuth retrofit: Retrofit,
): TokenService = retrofit.create(TokenService::class.java)

@Provides
@Singleton
fun provideMinSupportedVersionService(@NoneAuth retrofit: Retrofit): MinSupportedVersionService {
return retrofit.create(MinSupportedVersionService::class.java)
}
fun provideMinSupportedVersionService(
@NoneAuth retrofit: Retrofit,
): MinSupportedVersionService = retrofit.create(MinSupportedVersionService::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,45 @@ import okhttp3.Response
import okhttp3.Route
import javax.inject.Inject

class AuthAuthenticator @Inject constructor(
private val tokenPreferencesDataSource: TokenPreferencesDataSource,
private val refreshTokenUseCase: TokenService,
private val setAutoSignInUseCase: SetAutoSignInUseCase,
@ApplicationContext private val context: Context,
private val intentProvider: IntentProvider,
) : Authenticator {
class AuthAuthenticator
@Inject
constructor(
private val tokenPreferencesDataSource: TokenPreferencesDataSource,
private val refreshTokenUseCase: TokenService,
private val setAutoSignInUseCase: SetAutoSignInUseCase,
@ApplicationContext private val context: Context,
private val intentProvider: IntentProvider,
) : Authenticator {
override fun authenticate(
route: Route?,
response: Response,
): Request? {
val tokenResponse =
runCatching {
runBlocking {
refreshTokenUseCase.refreshAccessToken("Bearer ${tokenPreferencesDataSource.refreshToken.first()}")
}
}.onSuccess {
runBlocking {
tokenPreferencesDataSource.apply {
setAccessToken(it.data?.accessToken ?: return@runBlocking)
setRefreshToken(it.data.refreshToken ?: return@runBlocking)
}
}
}.onFailure {
runBlocking {
setAutoSignInUseCase.invoke(false)
}
ProcessPhoenix.triggerRebirth(context, intentProvider.getIntent())
}.getOrThrow()

override fun authenticate(route: Route?, response: Response): Request? {
val tokenResponse = runCatching {
runBlocking {
refreshTokenUseCase.refreshAccessToken("Bearer ${tokenPreferencesDataSource.refreshToken.first()}")
}
}.onSuccess {
runBlocking {
tokenPreferencesDataSource.apply {
setAccessToken(it.data?.accessToken ?: return@runBlocking)
setRefreshToken(it.data.refreshToken ?: return@runBlocking)
}
}
}.onFailure {
runBlocking {
setAutoSignInUseCase.invoke(false)
}
ProcessPhoenix.triggerRebirth(context, intentProvider.getIntent())
}.getOrThrow()
return response.request
.newBuilder()
.header(AUTHORIZATION, "Bearer ${tokenResponse.data?.accessToken}")
.build()
}

return response.request.newBuilder()
.header(AUTHORIZATION, "Bearer ${tokenResponse.data?.accessToken}")
.build()
companion object {
private const val AUTHORIZATION = "Authorization"
}
}

companion object {
private const val AUTHORIZATION = "Authorization"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@ class AmplitudeTracker(
context: Context,
apiKey: String,
) : Tracker {

private val amplitude: Amplitude? = if (apiKey.isNotEmpty()) {
Amplitude(
Configuration(
apiKey = apiKey,
context = context,
flushQueueSize = FLUSH_QUEUE_SIZE,
flushIntervalMillis = FLUSH_INTERVAL_MILLIS,
minTimeBetweenSessionsMillis = MIN_SESSION_INTERVAL,
trackingOptions = TrackingOptions().apply {
disableCarrier()
disableLanguage()
},
autocapture = autocaptureOptions {
+sessions
+appLifecycles
+screenViews
}
private val amplitude: Amplitude? =
if (apiKey.isNotEmpty()) {
Amplitude(
Configuration(
apiKey = apiKey,
context = context,
flushQueueSize = FLUSH_QUEUE_SIZE,
flushIntervalMillis = FLUSH_INTERVAL_MILLIS,
minTimeBetweenSessionsMillis = MIN_SESSION_INTERVAL,
trackingOptions =
TrackingOptions().apply {
disableCarrier()
disableLanguage()
},
autocapture =
autocaptureOptions {
+sessions
+appLifecycles
+screenViews
},
),
)
)
} else null
} else {
null
}

override fun trackEvent(
eventName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ sealed interface MainTabRoute : Route {
) : MainTabRoute

@Serializable
data class Explore(val authResultState: String = "NONE") :
MainTabRoute
data class Explore(
val authResultState: String = "NONE",
) : MainTabRoute

@Serializable
data object MyPage : MainTabRoute
}

sealed interface AuthRoute : Route {

@Serializable
data object AgreeTermsAndConditions : AuthRoute

Expand All @@ -38,7 +38,9 @@ sealed interface AuthRoute : Route {
) : AuthRoute

@Serializable
data class SelectedCharacter(val encodedUrl: String) : AuthRoute
data class SelectedCharacter(
val encodedUrl: String,
) : AuthRoute
}

sealed interface ExploreRoute : Route {
Expand Down
Loading