forked from loafle/openapi-generator-original
Stop using internal variable from okhttp3 (#17458)
This commit is contained in:
parent
5eab3cef19
commit
a67e07e132
@ -35,9 +35,6 @@ import okhttp3.Response
|
|||||||
{{#jvm-okhttp3}}
|
{{#jvm-okhttp3}}
|
||||||
import okhttp3.internal.Util.EMPTY_REQUEST
|
import okhttp3.internal.Util.EMPTY_REQUEST
|
||||||
{{/jvm-okhttp3}}
|
{{/jvm-okhttp3}}
|
||||||
{{#jvm-okhttp4}}
|
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
{{/jvm-okhttp4}}
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -77,6 +74,10 @@ import com.fasterxml.jackson.core.type.TypeReference
|
|||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
{{/moshi}}
|
{{/moshi}}
|
||||||
|
|
||||||
|
{{#jvm-okhttp4}}
|
||||||
|
{{#nonPublicApi}}internal {{/nonPublicApi}} val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
{{/jvm-okhttp4}}
|
||||||
|
|
||||||
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -411,6 +412,7 @@ import com.squareup.moshi.adapter
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}},
|
response.code{{#jvm-okhttp3}}(){{/jvm-okhttp3}},
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -26,6 +26,7 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -198,6 +199,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code(),
|
response.code(),
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -26,6 +26,7 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -198,6 +199,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code(),
|
response.code(),
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -218,6 +219,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.fasterxml.jackson.core.type.TypeReference
|
import com.fasterxml.jackson.core.type.TypeReference
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -218,6 +219,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -16,7 +16,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -31,6 +30,8 @@ import java.util.Locale
|
|||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -224,6 +225,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -32,6 +31,8 @@ import kotlin.coroutines.resumeWithException
|
|||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -232,6 +233,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
internal val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
internal open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
internal open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
internal companion object {
|
internal companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ internal open class ApiClient(val baseUrl: String, val client: OkHttpClient = de
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -26,6 +26,7 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -217,6 +218,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code(),
|
response.code(),
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import org.threeten.bp.OffsetDateTime
|
|||||||
import org.threeten.bp.OffsetTime
|
import org.threeten.bp.OffsetTime
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -30,6 +29,8 @@ import java.util.Locale
|
|||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -200,6 +201,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
@ -15,7 +15,6 @@ import okhttp3.MultipartBody
|
|||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Callback
|
import okhttp3.Callback
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.EMPTY_REQUEST
|
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -29,6 +28,8 @@ import java.time.OffsetTime
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import com.squareup.moshi.adapter
|
import com.squareup.moshi.adapter
|
||||||
|
|
||||||
|
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
|
||||||
|
|
||||||
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
|
||||||
companion object {
|
companion object {
|
||||||
protected const val ContentType = "Content-Type"
|
protected const val ContentType = "Content-Type"
|
||||||
@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
|||||||
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
|
||||||
|
|
||||||
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
|
||||||
|
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||||
return when {
|
return when {
|
||||||
response.isRedirect -> Redirection(
|
response.isRedirect -> Redirection(
|
||||||
response.code,
|
response.code,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user