[Kotlin] Allow other content-types when only interested in status-code / Unit (#19801)

* Allow Unit response

* Updating samples

* Improve comment for Unit shortcut
This commit is contained in:
roelwuytens-androme 2024-10-07 14:18:51 +02:00 committed by GitHub
parent 9a0fc5900f
commit 7d1e9997d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 105 additions and 42 deletions

View File

@ -167,8 +167,11 @@ import com.squareup.moshi.adapter
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -124,8 +124,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -124,8 +124,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -126,8 +126,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -127,8 +127,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ internal open class ApiClient(val baseUrl: String, val client: Call.Factory = de
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")

View File

@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")