From 1cb9eef30c95a6378d8679d5051991f9fbca801b Mon Sep 17 00:00:00 2001 From: Junhyeok Date: Sun, 15 Oct 2023 14:23:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor=20:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20matchApiService=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/network/di/ApiServiceModule.kt | 19 ------------------- .../core/network/di/DataSourceModule.kt | 6 ------ .../service/MatchDecisionApiService.kt | 19 ------------------- .../network/service/WaitingMatchApiService.kt | 14 -------------- 4 files changed, 58 deletions(-) delete mode 100644 core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchDecisionApiService.kt delete mode 100644 core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/WaitingMatchApiService.kt diff --git a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/ApiServiceModule.kt b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/ApiServiceModule.kt index 0256894b..39573b70 100644 --- a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/ApiServiceModule.kt +++ b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/ApiServiceModule.kt @@ -6,16 +6,13 @@ import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import okhttp3.OkHttpClient import online.partyrun.partyrunapplication.core.network.service.ResultApiService -import online.partyrun.partyrunapplication.core.network.service.MatchDecisionApiService import online.partyrun.partyrunapplication.core.network.service.MemberApiService import online.partyrun.partyrunapplication.core.network.service.BattleApiService import online.partyrun.partyrunapplication.core.network.service.MatchApiService import online.partyrun.partyrunapplication.core.network.service.PartyApiService import online.partyrun.partyrunapplication.core.network.service.SignInApiService import online.partyrun.partyrunapplication.core.network.service.SingleApiService -import online.partyrun.partyrunapplication.core.network.service.WaitingMatchApiService import retrofit2.Retrofit -import retrofit2.Retrofit.Builder import javax.inject.Singleton @Module @@ -30,22 +27,6 @@ object ApiServiceModule { .build() .create(SignInApiService::class.java) - @Singleton - @Provides - fun provideWaitingMatchApiService(@RESTOkHttpClient okHttpClient: OkHttpClient, retrofit: Builder): WaitingMatchApiService = - retrofit - .client(okHttpClient) - .build() - .create(WaitingMatchApiService::class.java) - - @Singleton - @Provides - fun provideMatchDecisionApiService(@RESTOkHttpClient okHttpClient: OkHttpClient, retrofit: Builder): MatchDecisionApiService = - retrofit - .client(okHttpClient) - .build() - .create(MatchDecisionApiService::class.java) - @Singleton @Provides fun provideResultApiService(@RESTOkHttpClient okHttpClient: OkHttpClient, retrofit: Retrofit.Builder): ResultApiService = diff --git a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/DataSourceModule.kt b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/DataSourceModule.kt index 4aad0e75..55eb792f 100644 --- a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/DataSourceModule.kt +++ b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/di/DataSourceModule.kt @@ -23,12 +23,10 @@ import online.partyrun.partyrunapplication.core.network.datasource.SingleDataSou import online.partyrun.partyrunapplication.core.network.service.BattleApiService import online.partyrun.partyrunapplication.core.network.service.MatchApiService import online.partyrun.partyrunapplication.core.network.service.ResultApiService -import online.partyrun.partyrunapplication.core.network.service.MatchDecisionApiService import online.partyrun.partyrunapplication.core.network.service.MemberApiService import online.partyrun.partyrunapplication.core.network.service.PartyApiService import online.partyrun.partyrunapplication.core.network.service.SignInApiService import online.partyrun.partyrunapplication.core.network.service.SingleApiService -import online.partyrun.partyrunapplication.core.network.service.WaitingMatchApiService import javax.inject.Singleton @Module @@ -40,15 +38,11 @@ object DataSourceModule { fun provideMatchDataSource( @SSEOkHttpClient okHttpClient: OkHttpClient, @SSERequestBuilder request: Request.Builder, - waitingMatchApiService: WaitingMatchApiService, - matchDecisionApiService: MatchDecisionApiService, matchApiService: MatchApiService ): MatchDataSource { return MatchDataSourceImpl( okHttpClient, request, - waitingMatchApiService, - matchDecisionApiService, matchApiService ) } diff --git a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchDecisionApiService.kt b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchDecisionApiService.kt deleted file mode 100644 index 11e050f8..00000000 --- a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchDecisionApiService.kt +++ /dev/null @@ -1,19 +0,0 @@ -package online.partyrun.partyrunapplication.core.network.service - -import online.partyrun.partyrunapplication.core.common.network.ApiResponse -import online.partyrun.partyrunapplication.core.network.model.request.MatchDecisionRequest -import online.partyrun.partyrunapplication.core.network.model.response.MatchStatusResponse -import retrofit2.http.Body -import retrofit2.http.POST - -interface MatchDecisionApiService { - @POST("/api/matching/members/join") - suspend fun acceptMatch( - @Body body: MatchDecisionRequest - ): ApiResponse - - @POST("/api/matching/members/join") - suspend fun declineMatch( - @Body body: MatchDecisionRequest - ): ApiResponse -} diff --git a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/WaitingMatchApiService.kt b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/WaitingMatchApiService.kt deleted file mode 100644 index f9cb1b59..00000000 --- a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/WaitingMatchApiService.kt +++ /dev/null @@ -1,14 +0,0 @@ -package online.partyrun.partyrunapplication.core.network.service - -import online.partyrun.partyrunapplication.core.common.network.ApiResponse -import online.partyrun.partyrunapplication.core.network.model.response.MatchStatusResponse -import online.partyrun.partyrunapplication.core.network.model.request.RunningDistanceRequest -import retrofit2.http.Body -import retrofit2.http.POST - -interface WaitingMatchApiService { - @POST("/api/waiting") - suspend fun registerMatch( - @Body body: RunningDistanceRequest - ): ApiResponse -} From 1c3ce9e5eee2b9f2e4cf6d42bcbc958e6b7384f6 Mon Sep 17 00:00:00 2001 From: Junhyeok Date: Sun, 15 Oct 2023 14:23:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor=20:=20MatchApiService=EB=A1=9C=20?= =?UTF-8?q?=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/datasource/MatchDataSourceImpl.kt | 13 ++++--------- .../core/network/service/MatchApiService.kt | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/datasource/MatchDataSourceImpl.kt b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/datasource/MatchDataSourceImpl.kt index 9e6f1078..bc4605ff 100644 --- a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/datasource/MatchDataSourceImpl.kt +++ b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/datasource/MatchDataSourceImpl.kt @@ -15,29 +15,25 @@ import online.partyrun.partyrunapplication.core.network.model.request.RunningDis import online.partyrun.partyrunapplication.core.network.model.response.CancelMatchResponse import online.partyrun.partyrunapplication.core.network.model.response.MatchInfoResponse import online.partyrun.partyrunapplication.core.network.service.MatchApiService -import online.partyrun.partyrunapplication.core.network.service.MatchDecisionApiService -import online.partyrun.partyrunapplication.core.network.service.WaitingMatchApiService import timber.log.Timber import javax.inject.Inject class MatchDataSourceImpl @Inject constructor( @SSEOkHttpClient private val okHttpClient: OkHttpClient, @SSERequestBuilder private val request: Request.Builder, - private val waitingMatchApiService: WaitingMatchApiService, - private val matchDecisionApiService: MatchDecisionApiService, private val matchApiService: MatchApiService ) : MatchDataSource { private lateinit var matchEventSource: EventSource private lateinit var matchResultSource: EventSource override suspend fun registerMatch(runningDistanceRequest: RunningDistanceRequest): ApiResponse = - waitingMatchApiService.registerMatch(runningDistanceRequest) + matchApiService.registerMatch(runningDistanceRequest) override suspend fun acceptMatch(matchDecisionRequest: MatchDecisionRequest): ApiResponse = - matchDecisionApiService.acceptMatch(matchDecisionRequest) + matchApiService.acceptMatch(matchDecisionRequest) override suspend fun declineMatch(matchDecisionRequest: MatchDecisionRequest): ApiResponse = - matchDecisionApiService.declineMatch(matchDecisionRequest) + matchApiService.declineMatch(matchDecisionRequest) override suspend fun getRunnerIds(): ApiResponse = matchApiService.getRunnerIds() @@ -45,12 +41,11 @@ class MatchDataSourceImpl @Inject constructor( override suspend fun cancelMatchWaitingEvent(): ApiResponse = matchApiService.cancelMatchWaitingEvent() - override fun createMatchEventSourceListener( onEvent: (data: String) -> Unit, onClosed: () -> Unit, onFailure: () -> Unit - ) : EventSourceListener { + ): EventSourceListener { return createEventListener(onEvent, onClosed, onFailure) } diff --git a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchApiService.kt b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchApiService.kt index 8598217c..19f8cf65 100644 --- a/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchApiService.kt +++ b/core/network/src/main/java/online/partyrun/partyrunapplication/core/network/service/MatchApiService.kt @@ -1,12 +1,30 @@ package online.partyrun.partyrunapplication.core.network.service import online.partyrun.partyrunapplication.core.common.network.ApiResponse +import online.partyrun.partyrunapplication.core.network.model.request.MatchDecisionRequest +import online.partyrun.partyrunapplication.core.network.model.request.RunningDistanceRequest import online.partyrun.partyrunapplication.core.network.model.response.CancelMatchResponse import online.partyrun.partyrunapplication.core.network.model.response.MatchInfoResponse +import online.partyrun.partyrunapplication.core.network.model.response.MatchStatusResponse +import retrofit2.http.Body import retrofit2.http.GET import retrofit2.http.POST interface MatchApiService { + @POST("/api/waiting") + suspend fun registerMatch( + @Body body: RunningDistanceRequest + ): ApiResponse + + @POST("/api/matching/members/join") + suspend fun acceptMatch( + @Body body: MatchDecisionRequest + ): ApiResponse + + @POST("/api/matching/members/join") + suspend fun declineMatch( + @Body body: MatchDecisionRequest + ): ApiResponse @GET("/api/matching/recent/members") suspend fun getRunnerIds(): ApiResponse