generated from DO-SOPT-ANDROID/do-sopt-android-repo-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.
reqres api 연결 - LIST USERS api 사용
- Loading branch information
Showing
22 changed files
with
190 additions
and
40 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
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 org.sopt.dosopttemplate.api | ||
|
||
import org.sopt.dosopttemplate.model.dto.resp.user.UserResp | ||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface UserAPI { | ||
@GET("api/users") | ||
fun getUserList( | ||
@Query("page") page: Int | ||
): Call<UserResp> | ||
} |
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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/sopt/dosopttemplate/db/remote/UserApiHelper.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,26 @@ | ||
package org.sopt.dosopttemplate.db.remote | ||
|
||
import android.util.Log | ||
import org.sopt.dosopttemplate.api.AuthAPI | ||
import org.sopt.dosopttemplate.api.UserAPI | ||
import org.sopt.dosopttemplate.model.dto.resp.user.UserResp | ||
import retrofit2.Call | ||
import retrofit2.Response | ||
|
||
class UserApiHelper(private val userAPI: UserAPI) { | ||
fun getUserList(page: Int) { | ||
userAPI.getUserList(page).enqueue(object: retrofit2.Callback<UserResp> { | ||
override fun onResponse(call: Call<UserResp>, response: Response<UserResp>) { | ||
if (response.isSuccessful && response.code() == 200) { | ||
Log.e("로그", "${response.body()}") | ||
} else { | ||
|
||
} | ||
} | ||
|
||
override fun onFailure(call: Call<UserResp>, t: Throwable) { | ||
t.printStackTrace() | ||
} | ||
}) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...osopttemplate/model/dto/resp/LoginResp.kt → ...template/model/dto/resp/auth/LoginResp.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
2 changes: 1 addition & 1 deletion
2
...sopttemplate/model/dto/resp/SignUpResp.kt → ...emplate/model/dto/resp/auth/SignUpResp.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
18 changes: 18 additions & 0 deletions
18
app/src/main/java/org/sopt/dosopttemplate/model/dto/resp/user/UserDataResp.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,18 @@ | ||
package org.sopt.dosopttemplate.model.dto.resp.user | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UserDataResp( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("email") | ||
val email: String, | ||
@SerialName("first_name") | ||
val first_name: String, | ||
@SerialName("last_name") | ||
val last_name: String, | ||
@SerialName("avatar") | ||
val avatar: String | ||
) |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/org/sopt/dosopttemplate/model/dto/resp/user/UserResp.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,20 @@ | ||
package org.sopt.dosopttemplate.model.dto.resp.user | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UserResp( | ||
@SerialName("page") | ||
val page: Int, | ||
@SerialName("per_page") | ||
val per_page: Int, | ||
@SerialName("total") | ||
val total: Int, | ||
@SerialName("total_pages") | ||
val total_pages: Int, | ||
@SerialName("data") | ||
val data: List<UserDataResp>, | ||
@SerialName("support") | ||
val support: UserSupportResp | ||
) |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/dosopttemplate/model/dto/resp/user/UserSupportResp.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 org.sopt.dosopttemplate.model.dto.resp.user | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UserSupportResp( | ||
@SerialName("url") | ||
val url: String, | ||
@SerialName("text") | ||
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
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
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.