forked from loafle/openapi-generator-original
[kotlin][KTOR] remove unnecessary dependencies (#13640)
* [kotlin][ktor] add set JSON as the ContentType header for ktor projects samples revert content type * update samples * fix multi-platform sample * revert docs * update samples and fix missing import on multiplatfrom * add missing sample
This commit is contained in:
parent
05f3b00f04
commit
3f4e3afab2
@ -20,8 +20,8 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
|||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
{{#jvm}}
|
{{#jvm}}
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
{{/jvm}}
|
{{/jvm}}
|
||||||
{{#multiplatform}}
|
{{#multiplatform}}
|
||||||
* Kotlin 1.5.10
|
* Kotlin 1.5.10
|
||||||
|
@ -11,7 +11,7 @@ wrapper {
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.6.10'
|
ext.kotlin_version = '1.6.10'
|
||||||
{{#jvm-ktor}}
|
{{#jvm-ktor}}
|
||||||
ext.ktor_version = '2.0.3'
|
ext.ktor_version = '2.1.2'
|
||||||
{{/jvm-ktor}}
|
{{/jvm-ktor}}
|
||||||
{{#jvm-retrofit2}}
|
{{#jvm-retrofit2}}
|
||||||
ext.retrofitVersion = '2.9.0'
|
ext.retrofitVersion = '2.9.0'
|
||||||
|
@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
|
|||||||
import io.ktor.client.request.request
|
import io.ktor.client.request.request
|
||||||
import io.ktor.client.request.setBody
|
import io.ktor.client.request.setBody
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.http.contentType
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
import io.ktor.http.Parameters
|
import io.ktor.http.Parameters
|
||||||
@ -34,11 +35,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
|||||||
import com.fasterxml.jackson.core.util.DefaultIndenter
|
import com.fasterxml.jackson.core.util.DefaultIndenter
|
||||||
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
|
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
|
||||||
{{/jackson}}
|
{{/jackson}}
|
||||||
import org.openapitools.client.auth.ApiKeyAuth
|
|
||||||
import org.openapitools.client.auth.Authentication
|
|
||||||
import org.openapitools.client.auth.HttpBasicAuth
|
|
||||||
import org.openapitools.client.auth.HttpBearerAuth
|
|
||||||
import org.openapitools.client.auth.OAuth
|
|
||||||
import {{packageName}}.auth.*
|
import {{packageName}}.auth.*
|
||||||
|
|
||||||
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(
|
||||||
@ -111,7 +107,7 @@ import {{packageName}}.auth.*
|
|||||||
* @param username Username
|
* @param username Username
|
||||||
*/
|
*/
|
||||||
fun setUsername(username: String) {
|
fun setUsername(username: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||||
?: throw Exception("No HTTP basic authentication configured")
|
?: throw Exception("No HTTP basic authentication configured")
|
||||||
auth.username = username
|
auth.username = username
|
||||||
}
|
}
|
||||||
@ -122,7 +118,7 @@ import {{packageName}}.auth.*
|
|||||||
* @param password Password
|
* @param password Password
|
||||||
*/
|
*/
|
||||||
fun setPassword(password: String) {
|
fun setPassword(password: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||||
?: throw Exception("No HTTP basic authentication configured")
|
?: throw Exception("No HTTP basic authentication configured")
|
||||||
auth.password = password
|
auth.password = password
|
||||||
}
|
}
|
||||||
@ -134,7 +130,7 @@ import {{packageName}}.auth.*
|
|||||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||||
*/
|
*/
|
||||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||||
?: throw Exception("No API key authentication configured")
|
?: throw Exception("No API key authentication configured")
|
||||||
auth.apiKey = apiKey
|
auth.apiKey = apiKey
|
||||||
}
|
}
|
||||||
@ -146,7 +142,7 @@ import {{packageName}}.auth.*
|
|||||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||||
*/
|
*/
|
||||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||||
?: throw Exception("No API key authentication configured")
|
?: throw Exception("No API key authentication configured")
|
||||||
auth.apiKeyPrefix = apiKeyPrefix
|
auth.apiKeyPrefix = apiKeyPrefix
|
||||||
}
|
}
|
||||||
@ -157,7 +153,7 @@ import {{packageName}}.auth.*
|
|||||||
* @param accessToken Access token
|
* @param accessToken Access token
|
||||||
*/
|
*/
|
||||||
fun setAccessToken(accessToken: String) {
|
fun setAccessToken(accessToken: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth?
|
||||||
?: throw Exception("No OAuth2 authentication configured")
|
?: throw Exception("No OAuth2 authentication configured")
|
||||||
auth.accessToken = accessToken
|
auth.accessToken = accessToken
|
||||||
}
|
}
|
||||||
@ -168,7 +164,7 @@ import {{packageName}}.auth.*
|
|||||||
* @param bearerToken The bearer token.
|
* @param bearerToken The bearer token.
|
||||||
*/
|
*/
|
||||||
fun setBearerToken(bearerToken: String) {
|
fun setBearerToken(bearerToken: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||||
?: throw Exception("No Bearer authentication configured")
|
?: throw Exception("No Bearer authentication configured")
|
||||||
auth.bearerToken = bearerToken
|
auth.bearerToken = bearerToken
|
||||||
}
|
}
|
||||||
@ -199,10 +195,11 @@ import {{packageName}}.auth.*
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
setBody(body)
|
setBody(body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
|
private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||||
for (authName in authNames) {
|
for (authName in authNames) {
|
||||||
|
@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.HttpClientConfig
|
import io.ktor.client.HttpClientConfig
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
import io.ktor.client.engine.HttpClientEngine
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.forms.FormDataContent
|
import io.ktor.client.request.forms.FormDataContent
|
||||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
import io.ktor.client.request.parameter
|
import io.ktor.client.request.parameter
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.http.content.PartData
|
import io.ktor.http.content.PartData
|
||||||
import kotlin.Unit
|
import kotlin.Unit
|
||||||
@ -153,9 +153,9 @@ import {{packageName}}.auth.*
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
this.setBody(body)
|
this.setBody(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ For more information, please visit [https://example.org](https://example.org)
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.HttpClientConfig
|
import io.ktor.client.HttpClientConfig
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
import io.ktor.client.engine.HttpClientEngine
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.forms.FormDataContent
|
import io.ktor.client.request.forms.FormDataContent
|
||||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
import io.ktor.client.request.parameter
|
import io.ktor.client.request.parameter
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.http.content.PartData
|
import io.ktor.http.content.PartData
|
||||||
import kotlin.Unit
|
import kotlin.Unit
|
||||||
@ -142,9 +142,9 @@ open class ApiClient(
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
this.setBody(body)
|
this.setBody(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.HttpClientConfig
|
import io.ktor.client.HttpClientConfig
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
import io.ktor.client.engine.HttpClientEngine
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.forms.FormDataContent
|
import io.ktor.client.request.forms.FormDataContent
|
||||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
import io.ktor.client.request.parameter
|
import io.ktor.client.request.parameter
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.http.content.PartData
|
import io.ktor.http.content.PartData
|
||||||
import kotlin.Unit
|
import kotlin.Unit
|
||||||
@ -142,9 +142,9 @@ open class ApiClient(
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
this.setBody(body)
|
this.setBody(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.HttpClientConfig
|
import io.ktor.client.HttpClientConfig
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
import io.ktor.client.engine.HttpClientEngine
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.forms.FormDataContent
|
import io.ktor.client.request.forms.FormDataContent
|
||||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
import io.ktor.client.request.parameter
|
import io.ktor.client.request.parameter
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.http.content.PartData
|
import io.ktor.http.content.PartData
|
||||||
import kotlin.Unit
|
import kotlin.Unit
|
||||||
@ -142,9 +142,9 @@ open class ApiClient(
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
this.setBody(body)
|
this.setBody(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ wrapper {
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.6.10'
|
ext.kotlin_version = '1.6.10'
|
||||||
ext.ktor_version = '2.0.3'
|
ext.ktor_version = '2.1.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://repo1.maven.org/maven2" }
|
maven { url "https://repo1.maven.org/maven2" }
|
||||||
|
@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
|
|||||||
import io.ktor.client.request.request
|
import io.ktor.client.request.request
|
||||||
import io.ktor.client.request.setBody
|
import io.ktor.client.request.setBody
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.http.contentType
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
import io.ktor.http.Parameters
|
import io.ktor.http.Parameters
|
||||||
@ -23,11 +24,6 @@ import io.ktor.http.takeFrom
|
|||||||
import io.ktor.serialization.gson.*
|
import io.ktor.serialization.gson.*
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import org.openapitools.client.auth.ApiKeyAuth
|
|
||||||
import org.openapitools.client.auth.Authentication
|
|
||||||
import org.openapitools.client.auth.HttpBasicAuth
|
|
||||||
import org.openapitools.client.auth.HttpBearerAuth
|
|
||||||
import org.openapitools.client.auth.OAuth
|
|
||||||
import org.openapitools.client.auth.*
|
import org.openapitools.client.auth.*
|
||||||
|
|
||||||
open class ApiClient(
|
open class ApiClient(
|
||||||
@ -71,7 +67,7 @@ open class ApiClient(
|
|||||||
* @param username Username
|
* @param username Username
|
||||||
*/
|
*/
|
||||||
fun setUsername(username: String) {
|
fun setUsername(username: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||||
?: throw Exception("No HTTP basic authentication configured")
|
?: throw Exception("No HTTP basic authentication configured")
|
||||||
auth.username = username
|
auth.username = username
|
||||||
}
|
}
|
||||||
@ -82,7 +78,7 @@ open class ApiClient(
|
|||||||
* @param password Password
|
* @param password Password
|
||||||
*/
|
*/
|
||||||
fun setPassword(password: String) {
|
fun setPassword(password: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||||
?: throw Exception("No HTTP basic authentication configured")
|
?: throw Exception("No HTTP basic authentication configured")
|
||||||
auth.password = password
|
auth.password = password
|
||||||
}
|
}
|
||||||
@ -94,7 +90,7 @@ open class ApiClient(
|
|||||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||||
*/
|
*/
|
||||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||||
?: throw Exception("No API key authentication configured")
|
?: throw Exception("No API key authentication configured")
|
||||||
auth.apiKey = apiKey
|
auth.apiKey = apiKey
|
||||||
}
|
}
|
||||||
@ -106,7 +102,7 @@ open class ApiClient(
|
|||||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||||
*/
|
*/
|
||||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||||
?: throw Exception("No API key authentication configured")
|
?: throw Exception("No API key authentication configured")
|
||||||
auth.apiKeyPrefix = apiKeyPrefix
|
auth.apiKeyPrefix = apiKeyPrefix
|
||||||
}
|
}
|
||||||
@ -117,7 +113,7 @@ open class ApiClient(
|
|||||||
* @param accessToken Access token
|
* @param accessToken Access token
|
||||||
*/
|
*/
|
||||||
fun setAccessToken(accessToken: String) {
|
fun setAccessToken(accessToken: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth?
|
||||||
?: throw Exception("No OAuth2 authentication configured")
|
?: throw Exception("No OAuth2 authentication configured")
|
||||||
auth.accessToken = accessToken
|
auth.accessToken = accessToken
|
||||||
}
|
}
|
||||||
@ -128,7 +124,7 @@ open class ApiClient(
|
|||||||
* @param bearerToken The bearer token.
|
* @param bearerToken The bearer token.
|
||||||
*/
|
*/
|
||||||
fun setBearerToken(bearerToken: String) {
|
fun setBearerToken(bearerToken: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||||
?: throw Exception("No Bearer authentication configured")
|
?: throw Exception("No Bearer authentication configured")
|
||||||
auth.bearerToken = bearerToken
|
auth.bearerToken = bearerToken
|
||||||
}
|
}
|
||||||
@ -159,10 +155,11 @@ open class ApiClient(
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
setBody(body)
|
setBody(body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
|
private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||||
for (authName in authNames) {
|
for (authName in authNames) {
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ wrapper {
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.6.10'
|
ext.kotlin_version = '1.6.10'
|
||||||
ext.ktor_version = '2.0.3'
|
ext.ktor_version = '2.1.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://repo1.maven.org/maven2" }
|
maven { url "https://repo1.maven.org/maven2" }
|
||||||
|
@ -12,6 +12,7 @@ import io.ktor.client.request.parameter
|
|||||||
import io.ktor.client.request.request
|
import io.ktor.client.request.request
|
||||||
import io.ktor.client.request.setBody
|
import io.ktor.client.request.setBody
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.http.contentType
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
import io.ktor.http.Parameters
|
import io.ktor.http.Parameters
|
||||||
@ -27,11 +28,6 @@ import com.fasterxml.jackson.databind.SerializationFeature
|
|||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
||||||
import com.fasterxml.jackson.core.util.DefaultIndenter
|
import com.fasterxml.jackson.core.util.DefaultIndenter
|
||||||
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
|
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
|
||||||
import org.openapitools.client.auth.ApiKeyAuth
|
|
||||||
import org.openapitools.client.auth.Authentication
|
|
||||||
import org.openapitools.client.auth.HttpBasicAuth
|
|
||||||
import org.openapitools.client.auth.HttpBearerAuth
|
|
||||||
import org.openapitools.client.auth.OAuth
|
|
||||||
import org.openapitools.client.auth.*
|
import org.openapitools.client.auth.*
|
||||||
|
|
||||||
open class ApiClient(
|
open class ApiClient(
|
||||||
@ -79,7 +75,7 @@ open class ApiClient(
|
|||||||
* @param username Username
|
* @param username Username
|
||||||
*/
|
*/
|
||||||
fun setUsername(username: String) {
|
fun setUsername(username: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||||
?: throw Exception("No HTTP basic authentication configured")
|
?: throw Exception("No HTTP basic authentication configured")
|
||||||
auth.username = username
|
auth.username = username
|
||||||
}
|
}
|
||||||
@ -90,7 +86,7 @@ open class ApiClient(
|
|||||||
* @param password Password
|
* @param password Password
|
||||||
*/
|
*/
|
||||||
fun setPassword(password: String) {
|
fun setPassword(password: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBasicAuth } as HttpBasicAuth?
|
||||||
?: throw Exception("No HTTP basic authentication configured")
|
?: throw Exception("No HTTP basic authentication configured")
|
||||||
auth.password = password
|
auth.password = password
|
||||||
}
|
}
|
||||||
@ -102,7 +98,7 @@ open class ApiClient(
|
|||||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||||
*/
|
*/
|
||||||
fun setApiKey(apiKey: String, paramName: String? = null) {
|
fun setApiKey(apiKey: String, paramName: String? = null) {
|
||||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName)} as ApiKeyAuth?
|
||||||
?: throw Exception("No API key authentication configured")
|
?: throw Exception("No API key authentication configured")
|
||||||
auth.apiKey = apiKey
|
auth.apiKey = apiKey
|
||||||
}
|
}
|
||||||
@ -114,7 +110,7 @@ open class ApiClient(
|
|||||||
* @param paramName The name of the API key parameter, or null or set the first key.
|
* @param paramName The name of the API key parameter, or null or set the first key.
|
||||||
*/
|
*/
|
||||||
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
fun setApiKeyPrefix(apiKeyPrefix: String, paramName: String? = null) {
|
||||||
val auth = authentications.values.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
val auth = authentications?.values?.firstOrNull { it is ApiKeyAuth && (paramName == null || paramName == it.paramName) } as ApiKeyAuth?
|
||||||
?: throw Exception("No API key authentication configured")
|
?: throw Exception("No API key authentication configured")
|
||||||
auth.apiKeyPrefix = apiKeyPrefix
|
auth.apiKeyPrefix = apiKeyPrefix
|
||||||
}
|
}
|
||||||
@ -125,7 +121,7 @@ open class ApiClient(
|
|||||||
* @param accessToken Access token
|
* @param accessToken Access token
|
||||||
*/
|
*/
|
||||||
fun setAccessToken(accessToken: String) {
|
fun setAccessToken(accessToken: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is OAuth } as OAuth?
|
val auth = authentications?.values?.firstOrNull { it is OAuth } as OAuth?
|
||||||
?: throw Exception("No OAuth2 authentication configured")
|
?: throw Exception("No OAuth2 authentication configured")
|
||||||
auth.accessToken = accessToken
|
auth.accessToken = accessToken
|
||||||
}
|
}
|
||||||
@ -136,7 +132,7 @@ open class ApiClient(
|
|||||||
* @param bearerToken The bearer token.
|
* @param bearerToken The bearer token.
|
||||||
*/
|
*/
|
||||||
fun setBearerToken(bearerToken: String) {
|
fun setBearerToken(bearerToken: String) {
|
||||||
val auth = authentications.values.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
val auth = authentications?.values?.firstOrNull { it is HttpBearerAuth } as HttpBearerAuth?
|
||||||
?: throw Exception("No Bearer authentication configured")
|
?: throw Exception("No Bearer authentication configured")
|
||||||
auth.bearerToken = bearerToken
|
auth.bearerToken = bearerToken
|
||||||
}
|
}
|
||||||
@ -167,10 +163,11 @@ open class ApiClient(
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
setBody(body)
|
setBody(body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
|
private fun <T: Any?> RequestConfig<T>.updateForAuth(authNames: kotlin.collections.List<String>) {
|
||||||
for (authName in authNames) {
|
for (authName in authNames) {
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import io.ktor.client.HttpClient
|
|||||||
import io.ktor.client.HttpClientConfig
|
import io.ktor.client.HttpClientConfig
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
import io.ktor.client.engine.HttpClientEngine
|
||||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||||
import io.ktor.serialization.kotlinx.json.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.request.forms.FormDataContent
|
import io.ktor.client.request.forms.FormDataContent
|
||||||
import io.ktor.client.request.forms.MultiPartFormDataContent
|
import io.ktor.client.request.forms.MultiPartFormDataContent
|
||||||
import io.ktor.client.request.header
|
import io.ktor.client.request.header
|
||||||
import io.ktor.client.request.parameter
|
import io.ktor.client.request.parameter
|
||||||
import io.ktor.client.statement.HttpResponse
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.serialization.kotlinx.json.json
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.http.content.PartData
|
import io.ktor.http.content.PartData
|
||||||
import kotlin.Unit
|
import kotlin.Unit
|
||||||
@ -146,9 +146,9 @@ open class ApiClient(
|
|||||||
}
|
}
|
||||||
this.method = requestConfig.method.httpMethod
|
this.method = requestConfig.method.httpMethod
|
||||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
|
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||||
this.setBody(body)
|
this.setBody(body)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
|
|
||||||
* Kotlin 1.4.30
|
* Kotlin 1.6.10
|
||||||
* Gradle 6.8.3
|
* Gradle 7.5
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user