Skip to content

Commit

Permalink
chore: update ApiFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannijunseokim committed Apr 1, 2024
1 parent 056d4d4 commit 876c4ab
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/univ/earthbreaker/namu/data/ApiFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ object ApiFactory {

val retrofitForGrowTreeServer: Retrofit by lazy {
Retrofit.Builder().baseUrl(BuildConfig.GROW_TREE_BASE_URL).client(client)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())).build()
.addConverterFactory(
Json.asConverterFactory("application/json".toMediaType()),
).build()
}

val retrofitForChatGPT: Retrofit by lazy {
Retrofit.Builder().baseUrl(BuildConfig.CHAT_GPT_BASE_URL).client(client)
val retrofitForOpenAiService: Retrofit by lazy {
Retrofit.Builder().baseUrl(BuildConfig.OPEN_AI_BASE_URL).client(client)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())).build()
}

inline fun <reified T> create(forWhichServer: Server): T =
when (forWhichServer) {
Server.GrowTreeServer -> retrofitForGrowTreeServer.create(T::class.java)
Server.ChatGPT -> retrofitForChatGPT.create(T::class.java)
Server.ChatGPT -> retrofitForOpenAiService.create(T::class.java)
}
}

Expand Down

0 comments on commit 876c4ab

Please sign in to comment.