[kotlin][client] update dependencies (#9629)

* [kotlin][client] update dependencies

* [kotlin][client] update sample projects

* [kotlin][client] fix update dependencies
This commit is contained in:
Bruno Coelho
2021-06-01 03:09:48 +01:00
committed by GitHub
parent 6cf4843249
commit 463ae10c4a
20 changed files with 154 additions and 154 deletions

View File

@@ -7,18 +7,18 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
{{#jvm-retrofit2}} {{#jvm-retrofit2}}
ext.retrofitVersion = '2.7.2' ext.retrofitVersion = '2.9.0'
{{/jvm-retrofit2}} {{/jvm-retrofit2}}
{{#useRxJava}} {{#useRxJava}}
ext.rxJavaVersion = '1.3.8' ext.rxJavaVersion = '1.3.8'
{{/useRxJava}} {{/useRxJava}}
{{#useRxJava2}} {{#useRxJava2}}
ext.rxJava2Version = '2.2.20' ext.rxJava2Version = '2.2.21'
{{/useRxJava2}} {{/useRxJava2}}
{{#useRxJava3}} {{#useRxJava3}}
ext.rxJava3Version = '3.0.10' ext.rxJava3Version = '3.0.12'
{{/useRxJava3}} {{/useRxJava3}}
repositories { repositories {
@@ -52,67 +52,67 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
{{#moshi}} {{#moshi}}
{{^moshiCodeGen}} {{^moshiCodeGen}}
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
{{/moshiCodeGen}} {{/moshiCodeGen}}
{{#moshiCodeGen}} {{#moshiCodeGen}}
compile "com.squareup.moshi:moshi:1.11.0" implementation "com.squareup.moshi:moshi:1.12.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.11.0" kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
{{/moshiCodeGen}} {{/moshiCodeGen}}
{{/moshi}} {{/moshi}}
{{#gson}} {{#gson}}
compile "com.google.code.gson:gson:2.8.6" implementation "com.google.code.gson:gson:2.8.7"
{{/gson}} {{/gson}}
{{#jackson}} {{#jackson}}
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1" implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.3"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.1" implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3"
{{/jackson}} {{/jackson}}
{{#kotlinx_serialization}} {{#kotlinx_serialization}}
compile "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1"
{{/kotlinx_serialization}} {{/kotlinx_serialization}}
{{#jvm-okhttp3}} {{#jvm-okhttp3}}
compile "com.squareup.okhttp3:okhttp:3.12.13" implementation "com.squareup.okhttp3:okhttp:3.12.13"
{{/jvm-okhttp3}} {{/jvm-okhttp3}}
{{#jvm-okhttp4}} {{#jvm-okhttp4}}
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
{{/jvm-okhttp4}} {{/jvm-okhttp4}}
{{#threetenbp}} {{#threetenbp}}
compile "org.threeten:threetenbp:1.5.0" implementation "org.threeten:threetenbp:1.5.1"
{{/threetenbp}} {{/threetenbp}}
{{#jvm-retrofit2}} {{#jvm-retrofit2}}
{{#hasOAuthMethods}} {{#hasOAuthMethods}}
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0" implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2"
{{/hasOAuthMethods}} {{/hasOAuthMethods}}
compile "com.squareup.okhttp3:logging-interceptor:4.9.0" implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
{{#useRxJava}} {{#useRxJava}}
compile "io.reactivex:rxjava:$rxJavaVersion" implementation "io.reactivex:rxjava:$rxJavaVersion"
compile "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion" implementation "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion"
{{/useRxJava}} {{/useRxJava}}
{{#useRxJava2}} {{#useRxJava2}}
compile "io.reactivex.rxjava2:rxjava:$rxJava2Version" implementation "io.reactivex.rxjava2:rxjava:$rxJava2Version"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion" implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
{{/useRxJava2}} {{/useRxJava2}}
{{#useRxJava3}} {{#useRxJava3}}
compile "io.reactivex.rxjava3:rxjava:$rxJava3Version" implementation "io.reactivex.rxjava3:rxjava:$rxJava3Version"
compile "com.squareup.retrofit2:adapter-rxjava3:2.9.0" implementation "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
{{/useRxJava3}} {{/useRxJava3}}
compile "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
{{#gson}} {{#gson}}
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion" implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
{{/gson}} {{/gson}}
{{#moshi}} {{#moshi}}
compile "com.squareup.retrofit2:converter-moshi:$retrofitVersion" implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
{{/moshi}} {{/moshi}}
{{#kotlinx_serialization}} {{#kotlinx_serialization}}
compile "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0" implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0"
{{/kotlinx_serialization}} {{/kotlinx_serialization}}
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion" implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
{{/jvm-retrofit2}} {{/jvm-retrofit2}}
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }
{{#kotlinx_serialization}} {{#kotlinx_serialization}}

View File

@@ -13,14 +13,13 @@ import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
class OAuthOkHttpClient( class OAuthOkHttpClient(
private var client: OkHttpClient private var client: OkHttpClient = OkHttpClient()
) : HttpClient { ) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class) @Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute( override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest, request: OAuthClientRequest,
@@ -39,7 +38,7 @@ class OAuthOkHttpClient(
} }
} }
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null val body: RequestBody? = if (request.body != null) request.body.toRequestBody(mediaType) else null
requestBuilder.method(requestMethod, body) requestBuilder.method(requestMethod, body)
try { try {
@@ -48,6 +47,7 @@ class OAuthOkHttpClient(
response.body?.string(), response.body?.string(),
response.body?.contentType()?.toString(), response.body?.contentType()?.toString(),
response.code, response.code,
response.headers.toMultimap(),
responseClass) responseClass)
} catch (e: IOException) { } catch (e: IOException) {
throw OAuthSystemException(e) throw OAuthSystemException(e)

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,8 +28,8 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "com.google.code.gson:gson:2.8.6" implementation "com.google.code.gson:gson:2.8.7"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,10 +28,10 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1" implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.12.3"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.1" implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -29,9 +29,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,8 +28,8 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "com.google.code.gson:gson:2.8.6" implementation "com.google.code.gson:gson:2.8.7"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -29,9 +29,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "com.squareup.moshi:moshi:1.11.0" implementation "com.squareup.moshi:moshi:1.12.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.11.0" kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,9 +28,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,9 +28,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,9 +28,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:3.12.13" implementation "com.squareup.okhttp3:okhttp:3.12.13"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,8 +7,8 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
ext.retrofitVersion = '2.7.2' ext.retrofitVersion = '2.9.0'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -31,14 +31,14 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0" implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2"
compile "com.squareup.okhttp3:logging-interceptor:4.9.0" implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
compile "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0" implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0"
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion" implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {

View File

@@ -13,14 +13,13 @@ import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
class OAuthOkHttpClient( class OAuthOkHttpClient(
private var client: OkHttpClient private var client: OkHttpClient = OkHttpClient()
) : HttpClient { ) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class) @Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute( override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest, request: OAuthClientRequest,
@@ -39,7 +38,7 @@ class OAuthOkHttpClient(
} }
} }
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null val body: RequestBody? = if (request.body != null) request.body.toRequestBody(mediaType) else null
requestBuilder.method(requestMethod, body) requestBuilder.method(requestMethod, body)
try { try {
@@ -48,6 +47,7 @@ class OAuthOkHttpClient(
response.body?.string(), response.body?.string(),
response.body?.contentType()?.toString(), response.body?.contentType()?.toString(),
response.code, response.code,
response.headers.toMultimap(),
responseClass) responseClass)
} catch (e: IOException) { } catch (e: IOException) {
throw OAuthSystemException(e) throw OAuthSystemException(e)

View File

@@ -7,9 +7,9 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
ext.retrofitVersion = '2.7.2' ext.retrofitVersion = '2.9.0'
ext.rxJava3Version = '3.0.10' ext.rxJava3Version = '3.0.12'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -30,15 +30,15 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0" implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2"
compile "com.squareup.okhttp3:logging-interceptor:4.9.0" implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
compile "io.reactivex.rxjava3:rxjava:$rxJava3Version" implementation "io.reactivex.rxjava3:rxjava:$rxJava3Version"
compile "com.squareup.retrofit2:adapter-rxjava3:2.9.0" implementation "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
compile "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-moshi:$retrofitVersion" implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion" implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -13,14 +13,13 @@ import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
class OAuthOkHttpClient( class OAuthOkHttpClient(
private var client: OkHttpClient private var client: OkHttpClient = OkHttpClient()
) : HttpClient { ) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class) @Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute( override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest, request: OAuthClientRequest,
@@ -39,7 +38,7 @@ class OAuthOkHttpClient(
} }
} }
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null val body: RequestBody? = if (request.body != null) request.body.toRequestBody(mediaType) else null
requestBuilder.method(requestMethod, body) requestBuilder.method(requestMethod, body)
try { try {
@@ -48,6 +47,7 @@ class OAuthOkHttpClient(
response.body?.string(), response.body?.string(),
response.body?.contentType()?.toString(), response.body?.contentType()?.toString(),
response.code, response.code,
response.headers.toMultimap(),
responseClass) responseClass)
} catch (e: IOException) { } catch (e: IOException) {
throw OAuthSystemException(e) throw OAuthSystemException(e)

View File

@@ -7,8 +7,8 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
ext.retrofitVersion = '2.7.2' ext.retrofitVersion = '2.9.0'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -29,13 +29,13 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0" implementation "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2"
compile "com.squareup.okhttp3:logging-interceptor:4.9.0" implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
compile "com.squareup.retrofit2:retrofit:$retrofitVersion" implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-moshi:$retrofitVersion" implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
compile "com.squareup.retrofit2:converter-scalars:$retrofitVersion" implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -13,14 +13,13 @@ import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
class OAuthOkHttpClient( class OAuthOkHttpClient(
private var client: OkHttpClient private var client: OkHttpClient = OkHttpClient()
) : HttpClient { ) : HttpClient {
constructor() : this(OkHttpClient())
@Throws(OAuthSystemException::class, OAuthProblemException::class) @Throws(OAuthSystemException::class, OAuthProblemException::class)
override fun <T : OAuthClientResponse?> execute( override fun <T : OAuthClientResponse?> execute(
request: OAuthClientRequest, request: OAuthClientRequest,
@@ -39,7 +38,7 @@ class OAuthOkHttpClient(
} }
} }
val body: RequestBody? = if (request.body != null) RequestBody.create(mediaType, request.body) else null val body: RequestBody? = if (request.body != null) request.body.toRequestBody(mediaType) else null
requestBuilder.method(requestMethod, body) requestBuilder.method(requestMethod, body)
try { try {
@@ -48,6 +47,7 @@ class OAuthOkHttpClient(
response.body?.string(), response.body?.string(),
response.body?.contentType()?.toString(), response.body?.contentType()?.toString(),
response.code, response.code,
response.headers.toMultimap(),
responseClass) responseClass)
} catch (e: IOException) { } catch (e: IOException) {
throw OAuthSystemException(e) throw OAuthSystemException(e)

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,9 +28,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,10 +28,10 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
compile "org.threeten:threetenbp:1.5.0" implementation "org.threeten:threetenbp:1.5.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,9 +28,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }

View File

@@ -7,7 +7,7 @@ wrapper {
} }
buildscript { buildscript {
ext.kotlin_version = '1.5.0' ext.kotlin_version = '1.5.10'
repositories { repositories {
maven { url "https://repo1.maven.org/maven2" } maven { url "https://repo1.maven.org/maven2" }
@@ -28,9 +28,9 @@ test {
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.11.0" implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
compile "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okhttp3:okhttp:4.9.1"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
} }