[kotlin-client] OkHttp call is now non-blocking (#10303)

* suspend method is now non-blocking

* added required imports

* generated the samples

* suspend method is now non-blocking

* added required imports

* generated the samples

* Cancelling the call when the coroutine is cancelled
Only use coroutines when requested
Not adding potentially unavailable imports

Co-authored-by: Guus Bloemsma <Guus.Bloemsma@Rabobank.nl>
This commit is contained in:
Guus Bloemsma
2021-09-03 05:56:31 +02:00
committed by GitHub
parent 8cc2bc4fa7
commit 490c747c2b
13 changed files with 103 additions and 3 deletions

View File

@@ -11,9 +11,13 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Request
import okhttp3.Headers
import okhttp3.MultipartBody
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
import java.io.IOException
import java.net.URLConnection
import java.time.LocalDate
import java.time.LocalDateTime
@@ -178,6 +182,7 @@ open class ApiClient(val baseUrl: String) {
}.build()
val response = client.newCall(request).execute()
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.getDefault())
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>