-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#54] 서버 기초세팅
- Loading branch information
Showing
8 changed files
with
74 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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/sopt/umbba_android/data/model/ApiFactory.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,34 @@ | ||
package com.sopt.umbba_android.data.model | ||
|
||
import com.google.firebase.BuildConfig | ||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import com.sopt.umbba_android.data.service.QuestionAnswerService | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import retrofit2.Retrofit | ||
|
||
object ApiFactory { | ||
private val client by lazy{ | ||
OkHttpClient.Builder().addInterceptor( | ||
HttpLoggingInterceptor().apply{ | ||
level = | ||
if(BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE | ||
} | ||
).build() | ||
} | ||
val retrofit: Retrofit by lazy{ | ||
Retrofit.Builder() | ||
.baseUrl("d") | ||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) | ||
.client(client) | ||
.build() | ||
} | ||
|
||
inline fun <reified T> create():T = retrofit.create(T::class.java) | ||
} | ||
|
||
object ServicePool{ | ||
val questionAnswerService = ApiFactory.create<QuestionAnswerService>() | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/sopt/umbba_android/data/model/request/AnswerRequestDto.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,5 @@ | ||
package com.sopt.umbba_android.data.model.request | ||
|
||
data class AnswerRequestDto( | ||
val answer: String | ||
) |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/umbba_android/data/service/HomeService.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,4 @@ | ||
package com.sopt.umbba_android.data.service | ||
|
||
interface HomeService { | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/umbba_android/data/service/ListService.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,4 @@ | ||
package com.sopt.umbba_android.data.service | ||
|
||
interface ListService { | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/umbba_android/data/service/OnBoardingService.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,4 @@ | ||
package com.sopt.umbba_android.data.service | ||
|
||
interface OnBoardingService { | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/sopt/umbba_android/data/service/QuestionAnswerService.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,16 @@ | ||
package com.sopt.umbba_android.data.service | ||
|
||
import com.sopt.umbba_android.data.model.request.AnswerRequestDto | ||
import com.sopt.umbba_android.data.model.response.AnswerResponseDto | ||
import com.sopt.umbba_android.data.model.response.QuestionAnswerResponseDto | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
|
||
interface QuestionAnswerService { | ||
@GET("/qna/today") | ||
suspend fun getQuestion() : QuestionAnswerResponseDto | ||
|
||
@POST("/qna/answer") | ||
suspend fun postAnswer(@Body answerRequestDto: AnswerRequestDto) : AnswerResponseDto | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/umbba_android/data/service/SettingService.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,4 @@ | ||
package com.sopt.umbba_android.data.service | ||
|
||
interface SettingService { | ||
} |