generated from NOW-SOPT-ANDROID/now-sopt-android-template
-
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.
Merge pull request #11 from NOW-SOPT-ANDROID/feat/week-xml4
[Week4] XML 필수 과제
- Loading branch information
Showing
32 changed files
with
687 additions
and
261 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
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/sopt/now/data/model/RequestSignInDto.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,12 @@ | ||
package com.sopt.now.data.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestSignInDto( | ||
@SerialName("authenticationId") | ||
val authenticationId: String, | ||
@SerialName("password") | ||
val password: String, | ||
) |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/sopt/now/data/model/RequestSignUpDto.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.now.data.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestSignUpDto( | ||
@SerialName("authenticationId") | ||
val authenticationId: String, | ||
@SerialName("password") | ||
val password: String, | ||
@SerialName("nickname") | ||
val nickname: String, | ||
@SerialName("phone") | ||
val phone: String, | ||
) |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/sopt/now/data/model/ResponseInfoDto.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,24 @@ | ||
package com.sopt.now.data.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseInfoDto( | ||
@SerialName("code") | ||
val code: Int, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: UserInfo, | ||
) | ||
|
||
@Serializable | ||
data class UserInfo( | ||
@SerialName("authenticationId") | ||
val authenticationId: String, | ||
@SerialName("nickname") | ||
val nickname: String, | ||
@SerialName("phone") | ||
val phone: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/sopt/now/data/model/ResponseSignInDto.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,12 @@ | ||
package com.sopt.now.data.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseSignInDto( | ||
@SerialName("code") | ||
val code: Int, | ||
@SerialName("message") | ||
val message: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/sopt/now/data/model/ResponseSignUpDto.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,12 @@ | ||
package com.sopt.now.data.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ResponseSignUpDto( | ||
@SerialName("code") | ||
val code: Int, | ||
@SerialName("message") | ||
val message: String, | ||
) |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/sopt/now/data/model/ResponseUserDto.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,29 @@ | ||
package com.sopt.now.data.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UserDataResponse( | ||
val page: Int, | ||
@SerialName("per_page") val perPage: Int, | ||
val total: Int, | ||
@SerialName("total_pages") val totalPages: Int, | ||
val data: List<UserData>, | ||
val support: Support, | ||
) | ||
|
||
@Serializable | ||
data class UserData( | ||
val id: Int, | ||
val email: String, | ||
@SerialName("first_name") val firstName: String, | ||
@SerialName("last_name") val lastName: String, | ||
val avatar: String, | ||
) | ||
|
||
@Serializable | ||
data class Support( | ||
val url: String, | ||
val text: String, | ||
) |
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,6 @@ | ||
package com.sopt.now.data.model | ||
|
||
data class SignInState( | ||
val isSuccess: Boolean, | ||
val message: String, | ||
) |
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,6 @@ | ||
package com.sopt.now.data.model | ||
|
||
data class SignUpState( | ||
val isSuccess: Boolean, | ||
val message: String, | ||
) |
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,41 @@ | ||
package com.sopt.now.data.module | ||
|
||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import com.sopt.now.BuildConfig | ||
import com.sopt.now.data.network.AuthService | ||
import com.sopt.now.data.network.FollowerService | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import retrofit2.Retrofit | ||
|
||
object ApiFactory { | ||
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL | ||
private const val FOLLOWER_URL: String = BuildConfig.FOLLOWER_URL | ||
|
||
private val interceptorClient = OkHttpClient().newBuilder() | ||
.addInterceptor(AuthInterceptor()).build() | ||
|
||
val baseRetrofit: Retrofit by lazy { | ||
Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.client(interceptorClient) | ||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
} | ||
|
||
val followerRetrofit: Retrofit by lazy { | ||
Retrofit.Builder() | ||
.baseUrl(FOLLOWER_URL) | ||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
} | ||
|
||
inline fun <reified T> createBase(): T = baseRetrofit.create(T::class.java) | ||
inline fun <reified T> createFollower(): T = followerRetrofit.create(T::class.java) | ||
} | ||
|
||
object ServicePool { | ||
val authService = ApiFactory.createBase<AuthService>() | ||
val followerService = ApiFactory.createFollower<FollowerService>() | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/sopt/now/data/module/AuthInterceptor.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,17 @@ | ||
package com.sopt.now.data.module | ||
|
||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
|
||
class AuthInterceptor : Interceptor { | ||
|
||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val originalRequest = chain.request() | ||
|
||
val newRequest = originalRequest.newBuilder() | ||
.addHeader("memberId", "495") | ||
.build() | ||
|
||
return chain.proceed(newRequest) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/sopt/now/data/network/AuthService.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,27 @@ | ||
package com.sopt.now.data.network | ||
|
||
import com.sopt.now.data.model.RequestSignInDto | ||
import com.sopt.now.data.model.RequestSignUpDto | ||
import com.sopt.now.data.model.ResponseInfoDto | ||
import com.sopt.now.data.model.ResponseSignInDto | ||
import com.sopt.now.data.model.ResponseSignUpDto | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
|
||
interface AuthService { | ||
@POST("member/join") | ||
fun signUp( | ||
@Body request: RequestSignUpDto, | ||
): Call<ResponseSignUpDto> | ||
|
||
@POST("member/login") | ||
fun signIn( | ||
@Body request: RequestSignInDto, | ||
): Call<ResponseSignInDto> | ||
|
||
@GET("member/info") | ||
fun memberInfo( | ||
): Call<ResponseInfoDto> | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/sopt/now/data/network/FollowerService.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,13 @@ | ||
package com.sopt.now.data.network | ||
|
||
import com.sopt.now.data.model.UserDataResponse | ||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface FollowerService { | ||
@GET("/api/users") | ||
fun getUserList( | ||
@Query("page") page: Int, | ||
): Call<UserDataResponse> | ||
} |
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
Oops, something went wrong.