Skip to content

Commit

Permalink
Ktor upgrade to 2.1.3 (#32)
Browse files Browse the repository at this point in the history
* ktor libs upgrade and compilation errors resolved

* migrating from deprecated plugin to content negotiation

* upgrading to the latest version
  • Loading branch information
zhemaituk authored Oct 31, 2022
1 parent 3224374 commit c0cff5f
Show file tree
Hide file tree
Showing 37 changed files with 50 additions and 21 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/
.DS_Store
/build
/captures
Expand Down
13 changes: 7 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ group = "com.github.mmoghaddam385"
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10")

val ktorVersion = "1.6.7"
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
implementation("io.ktor:ktor-client-serialization-jvm:$ktorVersion")
val ktorVersion = "2.1.3"
implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-websockets-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-okhttp-jvm:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")

// Annotation processor that generates Java builders for data classes
val ktBuilderVersion = "1.2.1"
implementation("com.thinkinglogic.builder:kotlin-builder-annotation:$ktBuilderVersion")
kapt("com.thinkinglogic.builder:kotlin-builder-processor:$ktBuilderVersion")

testImplementation("junit:junit:4.12")
testImplementation("junit:junit:4.13.2")
}

allprojects {
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:4.7.2")

// For custom CIO engine on defaultJvmHttpClientProvider
implementation("io.ktor:ktor-client-cio:1.3.1")
implementation("io.ktor:ktor-client-cio-jvm:2.1.2")

// For pretty printing data classes
implementation("com.tylerthrailkill.helpers:pretty-print:2.0.2")
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/io/polygon/kotlin/sdk/HttpClientProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package io.polygon.kotlin.sdk
import io.ktor.client.*
import io.ktor.client.engine.*
import io.ktor.client.engine.okhttp.*
import io.ktor.client.features.json.JsonFeature
import io.ktor.client.features.json.serializer.*
import io.ktor.client.features.websocket.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.websocket.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.json.Json
import okhttp3.Interceptor

Expand Down Expand Up @@ -55,8 +55,8 @@ constructor(
override fun buildClient() =
HttpClient(buildEngine()) {
install(WebSockets)
install(JsonFeature) {
serializer = KotlinxSerializer(Json {
install(ContentNegotiation) {
json(Json {
isLenient = true
ignoreUnknownKeys = true
})
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/io/polygon/kotlin/sdk/rest/Aggregates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/io/polygon/kotlin/sdk/rest/GroupedDaily.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import io.polygon.kotlin.sdk.rest.reference.PolygonReferenceClient

/** See [PolygonRestClient.getGroupedDailyAggregatesBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.polygon.kotlin.sdk.rest

import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.http.URLBuilder
import io.polygon.kotlin.sdk.DefaultJvmHttpClientProvider
Expand Down Expand Up @@ -92,7 +93,7 @@ constructor(
urlBuilderBlock: URLBuilder.() -> Unit
): T {
val url = baseUrlBuilder.apply(urlBuilderBlock).build()
return withHttpClient { httpClient -> httpClient.get(url) }
return withHttpClient { httpClient -> httpClient.get(url) }.body()
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.polygon.kotlin.sdk.rest.crypto

import com.thinkinglogic.builder.annotation.Builder
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.crypto

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonCryptoClient.getSupportedExchangesBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.polygon.kotlin.sdk.rest.crypto

import com.thinkinglogic.builder.annotation.Builder
import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonCryptoClient.getHistoricTradesBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.crypto

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonCryptoClient.getLastTradeBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.crypto

import io.ktor.http.*
import io.polygon.kotlin.sdk.rest.stocks.GainersOrLosersDirection
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.polygon.kotlin.sdk.rest.forex

import com.thinkinglogic.builder.annotation.Builder
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.forex

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonForexClient.getLastQuoteBlocking] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest.forex

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonForexClient.getRealTimeConversionBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.forex

import io.ktor.http.*
import io.polygon.kotlin.sdk.rest.stocks.GainersOrLosersDirection
import io.polygon.kotlin.sdk.rest.stocks.SnapshotAggregateDTO
import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonReferenceClient.getSupportedLocalesBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonReferenceClient.getMarketHolidaysBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonReferenceClient.getMarketStatusBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.polygon.kotlin.sdk.rest.reference

import com.thinkinglogic.builder.annotation.Builder
import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonReferenceClient.getStockFinancialsBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest.reference

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonReferenceClient.getTickerNewsBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.reference

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest.reference

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*

/** See [PolygonStocksClient.getConditionMappingsBlocking] */
suspend fun PolygonStocksClient.getConditionMappings(type: ConditionMappingTickerType): Map<String, String> =
polygonClient.fetchResult { path("v1", "meta", "conditions", type.urlParamName) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonStocksClient.getDailyOpenCloseBlocking] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*
import kotlinx.serialization.Serializable

/** See [PolygonStocksClient.getSupportedExchangesBlocking] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest.stocks

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.polygon.kotlin.sdk.rest.stocks

import com.thinkinglogic.builder.annotation.Builder
import com.thinkinglogic.builder.annotation.DefaultValue
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*
import io.polygon.kotlin.sdk.rest.AggregateDTO
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.polygon.kotlin.sdk.rest.stocks

import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.polygon.kotlin.sdk.websocket

import io.ktor.client.*
import io.ktor.client.features.websocket.*
import io.ktor.client.plugins.websocket.*
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.http.cio.websocket.*
import io.ktor.websocket.*
import io.polygon.kotlin.sdk.DefaultJvmHttpClientProvider
import io.polygon.kotlin.sdk.HttpClientProvider
import io.polygon.kotlin.sdk.ext.PolygonCompletionCallback
Expand Down

0 comments on commit c0cff5f

Please sign in to comment.