Skip to content

Commit

Permalink
Merge pull request #55 from Team-Umbba/feat/#54
Browse files Browse the repository at this point in the history
[Feat/#54] 서버 기초세팅
  • Loading branch information
ss99x2002 authored Jul 13, 2023
2 parents c0b4b61 + 28ce20d commit a1235e8
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ android {
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField "String", "UMBBA_BASE_URL", properties["UMBBA_BASE_URL"]
}

buildTypes {
Expand All @@ -41,6 +43,7 @@ android {
buildFeatures {
viewBinding true
dataBinding true
buildConfig true
}
}

Expand Down
34 changes: 34 additions & 0 deletions app/src/main/java/com/sopt/umbba_android/data/model/ApiFactory.kt
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>()
}
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
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.sopt.umbba_android.data.service

interface HomeService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.sopt.umbba_android.data.service

interface ListService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.sopt.umbba_android.data.service

interface OnBoardingService {
}
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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.sopt.umbba_android.data.service

interface SettingService {
}

0 comments on commit a1235e8

Please sign in to comment.