Skip to content

Commit

Permalink
feat: #10 AuthService 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 3, 2024
1 parent ad3506f commit 9bf6808
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/src/main/java/com/sopt/now/compose/data/ApiFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sopt.now.compose.data

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.compose.BuildConfig.AUTH_BASE_URL
import com.sopt.now.compose.BuildConfig.USER_API_URL
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import retrofit2.Retrofit

object ApiFactory {
fun retrofit(url: String): Retrofit =
Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()

inline fun <reified T, B> create(url: B): T = retrofit(url.toString()).create(T::class.java)
}

object ServicePool {
val authService = ApiFactory.create<AuthService, String>(AUTH_BASE_URL)
val userService = ApiFactory.create<AuthService, String>(USER_API_URL)
}
14 changes: 14 additions & 0 deletions app/src/main/java/com/sopt/now/compose/data/AuthService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sopt.now.compose.data

import com.sopt.now.compose.data.DTO.request.RequestSignupDto
import com.sopt.now.compose.data.DTO.response.ResponseSignupDto
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST

interface AuthService {
@POST("member/join")
fun signup(
@Body request: RequestSignupDto,
): Call<ResponseSignupDto>
}

0 comments on commit 9bf6808

Please sign in to comment.