Skip to content

Commit

Permalink
feature: Utility functions for getting non-null data from api response
Browse files Browse the repository at this point in the history
  • Loading branch information
utfunderscore committed Aug 20, 2024
1 parent 7e1d2cf commit c57fa18
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class ApiResponse<T>(
var failureReason: String?,
val response: T?,
) {
fun getFailureReason(): String = failureReason!!

fun getResponse(): T = response!!

companion object {
fun <T> success(data: T): ApiResponse<T> = ApiResponse(true, null, data)

Expand Down

0 comments on commit c57fa18

Please sign in to comment.