Created
February 2, 2019 04:08
-
-
Save kohendrix/6f4fae1952a3f399d8a9cb6f0548c9cd to your computer and use it in GitHub Desktop.
Volley Coroutines Sample
This file contains hidden or 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
| class TestRequest : HttpRequest() { | |
| companion object { | |
| private const val HEADER_AUTHORIZATION_KEY = "Authorization" | |
| private const val QUERY_KEY = "q" | |
| } | |
| override val method: Int = Request.Method.GET | |
| override val url: String = "https://www.testrequestforfun.com" | |
| override val queryParams: Map<String, String> = mapOf(QUERY_KEY to "paramTest") | |
| suspend fun request(): TestResponse { | |
| return request(TestResponse::class, JSONObject()) | |
| } | |
| override fun headers(): Map<String, String> { | |
| return mapOf(HEADER_AUTHORIZATION_KEY to "whateverauthvalue") | |
| } | |
| } | |
| class TestResponse : HttpResponse() { | |
| companion object { | |
| private const val TEST_KEY = "test" | |
| } | |
| lateinit var testValue: String | |
| override fun parseJson(json: JSONObject): HttpResponse { | |
| testValue = json.getString(TEST_KEY) | |
| return this | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment