-
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.
[Feat] network 기초 세팅, RetrofitModule, ServiceModule 구현 (#25)
* [build] kotlin-Serialization id 수정 * [init] network 모듈 * [build] hilt : migrate from kapt to ksp * [build] kotlin config * [build] testing 모듈에 JVM 플러그인 적용 * [build] ksp, hilt verson up * [build] Build-logic refactoring * [init] dataStore Module * [feat] UserCodeDataStore * [feat] DataStoreModule * [refactor] Preference 만드는 로직 분리 * [build] ktlint 적용 * [build] set ktlint, BASE_URL * [fix] deprecated된 manifast package 삭제 (nameSpace로 대체됨) * [build] Test 의존성 추가 * [build] META-INF/LICENSE* 파일 무시 * [add] allow usesCleartextTraffic, INTERNET Permission * [build] core:network BuildConfig, test, kotlinx-serialization 세팅 * [feat] RetrofitModule * [feat] ServiceModule, MatchingService * [feat] MatchingResponse * [feat] BaseResponse * [chore] postMatch -> matchProfile네이밍 변경 * [test] matchProfile * [chore] 불필요한 파일 삭제 * [sample] 서버 통신 Test~ (PR 머지 전에 삭제할 것임) * [CI] github secret key -> local property에 주입 * [chore] ktlint * [refactor] 줄 바꿈, ignoreUnKnownKeys 옵션 삭제 * [chore] naming 변경 * [refactor] release 버전도 FUNCH_DEBUG_BASE_URL 추가 * [refactor] Response 분리
- Loading branch information
Showing
21 changed files
with
423 additions
and
20 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
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
19 changes: 19 additions & 0 deletions
19
build-logic/convention/src/main/kotlin/com/moya/funch/plugins/JUnit5Plugin.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
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 |
---|---|---|
@@ -1,14 +1,46 @@ | ||
import org.jetbrains.kotlin.konan.properties.Properties | ||
|
||
plugins { | ||
alias(libs.plugins.ktlint) | ||
alias(libs.plugins.funch.android.library) | ||
alias(libs.plugins.funch.kotlinx.serialization) | ||
alias(libs.plugins.funch.junit5) | ||
} | ||
|
||
val properties = | ||
Properties().apply { | ||
load(rootProject.file("local.properties").inputStream()) | ||
} | ||
android { | ||
namespace = "com.moja.funch.network" | ||
|
||
buildTypes { | ||
getByName("release") { | ||
buildConfigField( | ||
"String", | ||
"FUNCH_DEBUG_BASE_URL", | ||
properties.getProperty("FUNCH_DEBUG_BASE_URL"), | ||
) | ||
} | ||
getByName("debug") { | ||
buildConfigField( | ||
"String", | ||
"FUNCH_DEBUG_BASE_URL", | ||
properties.getProperty("FUNCH_DEBUG_BASE_URL"), | ||
) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(projects.core.datastore) | ||
implementation(projects.core.testing) | ||
|
||
implementation(libs.bundles.retrofit) | ||
implementation(platform(libs.okhttp.bom)) | ||
implementation(libs.okhttp.logging.interceptor) | ||
// test | ||
testImplementation(libs.mockk) | ||
testImplementation(libs.kotlin.coroutines.test) | ||
testImplementation(libs.mockk.webserver) | ||
} |
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
core/network/src/main/java/com/moya/funch/network/di/RetrofitModule.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,67 @@ | ||
package com.moya.funch.network.di | ||
|
||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import com.moja.funch.network.BuildConfig | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.Interceptor | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import retrofit2.Converter | ||
import retrofit2.Retrofit | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object RetrofitModule { | ||
@Provides | ||
@Singleton | ||
fun provideJson(): Json = | ||
Json { | ||
coerceInputValues = true | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideJsonConverterFactory(json: Json): Converter.Factory { | ||
return json.asConverterFactory("application/json".toMediaType()) | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideLoggingInterceptor(): Interceptor = | ||
HttpLoggingInterceptor().setLevel( | ||
if (BuildConfig.DEBUG) { | ||
HttpLoggingInterceptor.Level.BODY | ||
} else { | ||
HttpLoggingInterceptor.Level.NONE | ||
}, | ||
) | ||
|
||
@Singleton | ||
@Provides | ||
fun provideOkHttpClient(logInterceptor: Interceptor): OkHttpClient = | ||
OkHttpClient | ||
.Builder() | ||
.addInterceptor(logInterceptor) | ||
.connectTimeout(60, TimeUnit.SECONDS) | ||
.readTimeout(30, TimeUnit.SECONDS) | ||
.writeTimeout(15, TimeUnit.SECONDS).build() | ||
|
||
@Singleton | ||
@Provides | ||
fun provideRetrofit( | ||
client: OkHttpClient, | ||
converterFactory: Converter.Factory, | ||
): Retrofit = | ||
Retrofit.Builder() | ||
.baseUrl(BuildConfig.FUNCH_DEBUG_BASE_URL) | ||
.client(client) | ||
.addConverterFactory(converterFactory) | ||
.build() | ||
} |
18 changes: 18 additions & 0 deletions
18
core/network/src/main/java/com/moya/funch/network/di/ServiceModule.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,18 @@ | ||
package com.moya.funch.network.di | ||
|
||
import com.moya.funch.network.service.MatchingService | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import retrofit2.Retrofit | ||
import retrofit2.create | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ServiceModule { | ||
@Provides | ||
@Singleton | ||
fun providesMatchingService(retrofit: Retrofit): MatchingService = retrofit.create() | ||
} |
10 changes: 10 additions & 0 deletions
10
core/network/src/main/java/com/moya/funch/network/dto/request/MatchingRequest.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,10 @@ | ||
package com.moya.funch.network.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class MatchingRequest( | ||
@SerialName("requestMemberId") val userId: String, | ||
@SerialName("targetMemberCode") val targetCode: String, | ||
) |
14 changes: 14 additions & 0 deletions
14
core/network/src/main/java/com/moya/funch/network/dto/response/BaseResponse.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,14 @@ | ||
package com.moya.funch.network.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponse<T>( | ||
@SerialName("status") | ||
val status: Int, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: T, | ||
) |
12 changes: 12 additions & 0 deletions
12
core/network/src/main/java/com/moya/funch/network/dto/response/match/ChemistryResponse.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,12 @@ | ||
package com.moya.funch.network.dto.response.match | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ChemistryResponse( | ||
@SerialName("title") | ||
val title: String = "", | ||
@SerialName("description") | ||
val description: String = "", | ||
) |
19 changes: 19 additions & 0 deletions
19
core/network/src/main/java/com/moya/funch/network/dto/response/match/MatchingResponse.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,19 @@ | ||
package com.moya.funch.network.dto.response.match | ||
|
||
import com.moya.funch.network.dto.response.profile.ProfileResponse | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class MatchingResponse( | ||
@SerialName("profile") | ||
val profile: ProfileResponse = ProfileResponse(), | ||
@SerialName("similarity") | ||
val similarity: Int = 0, | ||
@SerialName("chemistryInfos") | ||
val chemistryInfos: List<ChemistryResponse> = listOf(), | ||
@SerialName("recommendInfos") | ||
val recommends: List<RecommendResponse> = listOf(), | ||
@SerialName("subwayInfos") | ||
val subways: List<SubwayResponse> = listOf(), | ||
) |
10 changes: 10 additions & 0 deletions
10
core/network/src/main/java/com/moya/funch/network/dto/response/match/RecommendResponse.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,10 @@ | ||
package com.moya.funch.network.dto.response.match | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RecommendResponse( | ||
@SerialName("title") | ||
val title: String = "", | ||
) |
12 changes: 12 additions & 0 deletions
12
core/network/src/main/java/com/moya/funch/network/dto/response/match/SubwayResponse.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,12 @@ | ||
package com.moya.funch.network.dto.response.match | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SubwayResponse( | ||
@SerialName("lines") | ||
val lines: List<String> = listOf(), | ||
@SerialName("name") | ||
val name: String = "", | ||
) |
20 changes: 20 additions & 0 deletions
20
core/network/src/main/java/com/moya/funch/network/dto/response/profile/ProfileResponse.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,20 @@ | ||
package com.moya.funch.network.dto.response.profile | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ProfileResponse( | ||
@SerialName("name") | ||
val name: String = "", | ||
@SerialName("jobGroup") | ||
val jobGroup: String = "", | ||
@SerialName("clubs") | ||
val clubs: List<String> = listOf(), | ||
@SerialName("mbti") | ||
val mbti: String = "", | ||
@SerialName("constellation") | ||
val constellation: String = "", | ||
@SerialName("subwayNames") | ||
val subwayNames: List<String> = listOf(), | ||
) |
Oops, something went wrong.