-
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.
[#37] Retrofit CallAdapter, Gson Converter 커스텀
- 리모트 푸시를 위한 커밋
- Loading branch information
Showing
8 changed files
with
134 additions
and
87 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
app/src/main/java/com/moyerun/moyeorun_android/common/exceptions/ApiException.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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.moyerun.moyeorun_android.common.exceptions | ||
|
||
import com.moyerun.moyeorun_android.network.api.Error | ||
import com.moyerun.moyeorun_android.network.api.ApiFailure | ||
|
||
class ApiException(val url: String, val error: Error) : RuntimeException() { | ||
class ApiException(val url: String, val apiFailure: ApiFailure) : RuntimeException() { | ||
val case: String | ||
get() = error.case | ||
get() = apiFailure.case | ||
|
||
override val message: String? | ||
get() = error.message | ||
get() = apiFailure.message | ||
} |
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
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/moyerun/moyeorun_android/network/api/ApiService.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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
package com.moyerun.moyeorun_android.network.api | ||
|
||
import com.moyerun.moyeorun_android.network.calladapter.ApiResult | ||
import com.moyerun.moyeorun_android.network.model.TestSuccess | ||
import retrofit2.http.GET | ||
|
||
interface ApiService { | ||
|
||
@GET() | ||
suspend fun getSuccessTest(): ApiResult<TestSuccess> | ||
} |
9 changes: 6 additions & 3 deletions
9
app/src/main/java/com/moyerun/moyeorun_android/network/calladapter/ApiResult.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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package com.moyerun.moyeorun_android.network.calladapter | ||
|
||
import com.moyerun.moyeorun_android.network.api.ApiFailure | ||
import com.moyerun.moyeorun_android.network.api.ApiSuccess | ||
|
||
/** | ||
* Success : API 호출 성공 시, body를 Wrapping 합니다. | ||
* Failure : API 호출 실패 시, throwable을 Wrpping 합니다. | ||
*/ | ||
sealed class ApiResult<out T> { | ||
data class Success<T>(val body: T) : ApiResult<T>() | ||
data class Failure(val throwable: Throwable) : ApiResult<Nothing>() | ||
sealed class ApiResult<T> { | ||
data class Success<T>(val body: T) : ApiResult<ApiSuccess<T>>() | ||
data class Failure<T>(val throwable: Throwable, val errorBody: T) : ApiResult<ApiFailure>() | ||
} |
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
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/moyerun/moyeorun_android/network/model/TestSuccess.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,6 @@ | ||
package com.moyerun.moyeorun_android.network.model | ||
|
||
data class TestSuccess( | ||
val id: Int, | ||
val name: String | ||
) |