diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/retro/IFrost.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/facebook/retro/IFrost.kt | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/retro/IFrost.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/retro/IFrost.kt index 6c50fa74..b9048fe0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/retro/IFrost.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/retro/IFrost.kt @@ -1,7 +1,11 @@ package com.pitchedapps.frost.facebook.retro import com.pitchedapps.frost.facebook.token +import com.pitchedapps.frost.utils.L +import okhttp3.ResponseBody import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Query @@ -11,6 +15,22 @@ import retrofit2.http.Query interface IFrost { @GET("me") - fun me(@Query(ACCESS_TOKEN) accessToken: String? = token): Call<Me> + fun me(): Call<ResponseBody> + +} + +fun <T> Call<T>.enqueueFrost(success: (call: Call<T>, response: Response<T>) -> Unit) { + this.enqueue(object : Callback<T> { + override fun onFailure(call: Call<T>?, t: Throwable?) { + L.e("Frost enqueue error") + } + + override fun onResponse(call: Call<T>, response: Response<T>) { + if (response.isSuccessful && !call.isCanceled) + success.invoke(call, response) + else + L.e("Frost response received but not successful") + } + }) }
\ No newline at end of file |