This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
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.
[feature/net-module] 네트워크 모듈 쪽 Config (#35)
* .DS_STORE 파일 ignore 등록 * feat: Add BuildConfig api properties * [feature/net-module] 상수 주입받는 모듈 생성 * [feature/net-module] 어노테이션 명 변경 * [feature/net-module] Json, Retrofit, OkHttp 설정 * [feature/net-module] kotlinx-datetime 의존성 추가 * [feature/net-module] kotlinx-datatime 의존성 추가 * [feature/net-module] DTO 패키지/모델 추가 * [feature/net-module] Model명 변경 * [feature/net-module] 리모트 모듈 정의하고 StampService 만들기 * [feature/net-module] Lint 정리 * [feature/net-module] yml에 apiKey 정보 넣기 * [feature/net-module] Action 빌드 스텝 이름 변경 * [feature/net-module] 스탬프 수정 API * [feature/net-module] 스탬프 등록 API Co-authored-by: jinsu4755 <parkjinsu4755@gmail.com>
- Loading branch information
Showing
13 changed files
with
171 additions
and
0 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
Empty file.
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/stamp/data/model/response/ResponseModifyStampDto.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,8 @@ | ||
package org.sopt.stamp.data.model.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseModifyStampDto( | ||
val stampId: Int, | ||
) |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/sopt/stamp/data/model/response/ResponseStampDto.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,15 @@ | ||
package org.sopt.stamp.data.model.response | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseStampDto( | ||
val createdAt: Instant? = null, | ||
val updatedAt: Instant? = null, | ||
val id: Long, | ||
val contents: String, | ||
val images: List<String>, | ||
val userId: Long, | ||
val missionId: Int, | ||
) |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/org/sopt/stamp/data/remote/service/StampService.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,35 @@ | ||
package org.sopt.stamp.data.remote.service | ||
|
||
import okhttp3.MultipartBody | ||
import okhttp3.RequestBody | ||
import org.sopt.stamp.data.model.response.ResponseModifyStampDto | ||
import org.sopt.stamp.data.model.response.ResponseStampDto | ||
import retrofit2.http.GET | ||
import retrofit2.http.Multipart | ||
import retrofit2.http.POST | ||
import retrofit2.http.PUT | ||
import retrofit2.http.Part | ||
import retrofit2.http.Path | ||
|
||
interface StampService { | ||
@GET("stamp/{missionId}") | ||
suspend fun retrieveStamp( | ||
@Path("missionId") missionId: Int | ||
): ResponseStampDto | ||
|
||
@Multipart | ||
@PUT("stamp/{missionId}") | ||
suspend fun modifyStamp( | ||
@Path("missionId") missionId: Int, | ||
@Part stampContent: RequestBody, | ||
@Part imageUrl: MultipartBody.Part? = null, | ||
): ResponseModifyStampDto | ||
|
||
@Multipart | ||
@POST("stamp/{missionId}") | ||
suspend fun registerStamp( | ||
@Path("missionId") missionId: Int, | ||
@Part stampContent: RequestBody, | ||
@Part imageUrl: MultipartBody.Part? = null, | ||
): ResponseStampDto | ||
} |
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,44 @@ | ||
package org.sopt.stamp.di | ||
|
||
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.ExperimentalSerializationApi | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import org.sopt.stamp.di.constant.Constant | ||
import org.sopt.stamp.di.constant.Strings | ||
import retrofit2.Retrofit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ConfigModule { | ||
@Provides | ||
@Singleton | ||
fun provideSerializer() = Json { | ||
prettyPrint = true | ||
isLenient = true | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideHttpClient() = OkHttpClient.Builder() | ||
.build() | ||
|
||
@OptIn(ExperimentalSerializationApi::class) | ||
@Provides | ||
@Singleton | ||
fun provideRetrofit( | ||
@Strings(Constant.SOPTAMP_API_KEY) baseUrl: String, | ||
client: OkHttpClient, | ||
json: Json | ||
): Retrofit = Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.client(client) | ||
.addConverterFactory(json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
} |
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 org.sopt.stamp.di | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.stamp.BuildConfig | ||
import org.sopt.stamp.di.constant.Strings | ||
import org.sopt.stamp.di.constant.Constant | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ConstantModule { | ||
@Provides | ||
@Singleton | ||
@Strings(Constant.SOPTAMP_API_KEY) | ||
fun provideBaseUrl() = BuildConfig.SOPTAMP_API_KEY | ||
} |
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 org.sopt.stamp.di | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.stamp.data.remote.service.StampService | ||
import retrofit2.Retrofit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object RemoteModule { | ||
@Provides | ||
@Singleton | ||
fun provideStampService( | ||
retrofit: Retrofit | ||
): StampService = retrofit.create(StampService::class.java) | ||
} |
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 org.sopt.stamp.di.constant | ||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class Strings(val value: Constant) | ||
|
||
enum class Constant { | ||
SOPTAMP_API_KEY | ||
} |
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