From d4c5e849bf62a618754023dd13843232a0da4f82 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 30 Jun 2022 13:15:19 +0600 Subject: [PATCH] deprecate BodyPair --- CHANGELOG.md | 4 ++++ .../ktor/client/StandardHttpClientGetPost.kt | 13 +++++++------ .../ktor/client/crud/KtorWriteStandardCrudRepo.kt | 8 ++++---- .../key_value/KtorWriteStandardKeyValueRepo.kt | 6 +++--- .../one_to_many/KtorWriteOneToManyKeyValueRepo.kt | 10 +++++----- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1fd315e4f5..f1b2c4f63ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.11.11 +* `Ktor`: + * `Client`: + * `BodyPair` has been deprecated + ## 0.11.10 * `Repos`: diff --git a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt index 21c5b28aede..a36d817a06e 100644 --- a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt +++ b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt @@ -12,6 +12,7 @@ import io.ktor.http.* import io.ktor.utils.io.core.ByteReadPacket import kotlinx.serialization.* +@Deprecated("This class will be removed in next") typealias BodyPair = Pair, T> class UnifiedRequester( @@ -33,7 +34,7 @@ class UnifiedRequester( suspend fun unipost( url: String, - bodyInfo: BodyPair, + bodyInfo: Pair, BodyType>, resultDeserializer: DeserializationStrategy ) = client.unipost(url, bodyInfo, resultDeserializer, serialFormat) @@ -52,7 +53,7 @@ class UnifiedRequester( url: String, filename: String, inputProvider: InputProvider, - otherData: BodyPair, + otherData: Pair, BodyType>, resultDeserializer: DeserializationStrategy, mimetype: String = "*/*", additionalParametersBuilder: FormBuilder.() -> Unit = {}, @@ -75,7 +76,7 @@ class UnifiedRequester( suspend fun unimultipart( url: String, mppFile: MPPFile, - otherData: BodyPair, + otherData: Pair, BodyType>, resultDeserializer: DeserializationStrategy, mimetype: String = "*/*", additionalParametersBuilder: FormBuilder.() -> Unit = {}, @@ -120,7 +121,7 @@ fun SerializationStrategy.encodeUrlQueryValue( suspend fun HttpClient.unipost( url: String, - bodyInfo: BodyPair, + bodyInfo: Pair, BodyType>, resultDeserializer: DeserializationStrategy, serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat ) = post(url) { @@ -162,7 +163,7 @@ suspend fun HttpClient.unimultipart( suspend fun HttpClient.unimultipart( url: String, filename: String, - otherData: BodyPair, + otherData: Pair, BodyType>, inputProvider: InputProvider, resultDeserializer: DeserializationStrategy, mimetype: String = "*/*", @@ -220,7 +221,7 @@ suspend fun HttpClient.unimultipart( suspend fun HttpClient.unimultipart( url: String, mppFile: MPPFile, - otherData: BodyPair, + otherData: Pair, BodyType>, resultDeserializer: DeserializationStrategy, mimetype: String = "*/*", additionalParametersBuilder: FormBuilder.() -> Unit = {}, diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt index 1b417090bb5..e4dddd8f7e0 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/crud/KtorWriteStandardCrudRepo.kt @@ -56,25 +56,25 @@ class KtorWriteStandardCrudRepo ( override suspend fun create(values: List): List = unifiedRequester.unipost( buildStandardUrl(baseUrl, createRouting), - BodyPair(listInputSerializer, values), + Pair(listInputSerializer, values), listObjectsSerializer ) override suspend fun update(id: IdType, value: InputValue): ObjectType? = unifiedRequester.unipost( buildStandardUrl(baseUrl, updateRouting), - BodyPair(inputUpdateSerializer, id to value), + Pair(inputUpdateSerializer, id to value), objectsNullableSerializer ) override suspend fun update(values: List>): List = unifiedRequester.unipost( buildStandardUrl(baseUrl, updateManyRouting), - BodyPair(listInputUpdateSerializer, values), + Pair(listInputUpdateSerializer, values), listObjectsSerializer ) override suspend fun deleteById(ids: List) = unifiedRequester.unipost( buildStandardUrl(baseUrl, deleteByIdRouting), - BodyPair(listIdsSerializer, ids), + Pair(listIdsSerializer, ids), Unit.serializer() ) } diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt index 4b51836ab57..9ebf015600e 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt @@ -45,7 +45,7 @@ class KtorWriteStandardKeyValueRepo ( baseUrl, setRoute ), - BodyPair(keyValueMapSerializer, toSet), + Pair(keyValueMapSerializer, toSet), Unit.serializer() ) @@ -54,7 +54,7 @@ class KtorWriteStandardKeyValueRepo ( baseUrl, unsetRoute, ), - BodyPair(keysListSerializer, toUnset), + Pair(keysListSerializer, toUnset), Unit.serializer() ) @@ -63,7 +63,7 @@ class KtorWriteStandardKeyValueRepo ( baseUrl, unsetWithValuesRoute, ), - BodyPair(valuesListSerializer, toUnset), + Pair(valuesListSerializer, toUnset), Unit.serializer() ) } diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt index 6430b7252e2..6a9670b345c 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/one_to_many/KtorWriteOneToManyKeyValueRepo.kt @@ -47,7 +47,7 @@ class KtorWriteOneToManyKeyValueRepo ( baseUrl, removeRoute, ), - BodyPair(keyValueMapSerializer, toRemove), + Pair(keyValueMapSerializer, toRemove), Unit.serializer(), ) @@ -56,7 +56,7 @@ class KtorWriteOneToManyKeyValueRepo ( baseUrl, addRoute, ), - BodyPair(keyValueMapSerializer, toAdd), + Pair(keyValueMapSerializer, toAdd), Unit.serializer(), ) override suspend fun clear(k: Key) = unifiedRequester.unipost( @@ -64,7 +64,7 @@ class KtorWriteOneToManyKeyValueRepo ( baseUrl, clearRoute, ), - BodyPair(keySerializer, k), + Pair(keySerializer, k), Unit.serializer(), ) @@ -73,7 +73,7 @@ class KtorWriteOneToManyKeyValueRepo ( baseUrl, clearWithValueRoute, ), - BodyPair(valueSerializer, v), + Pair(valueSerializer, v), Unit.serializer(), ) @@ -82,7 +82,7 @@ class KtorWriteOneToManyKeyValueRepo ( baseUrl, setRoute, ), - BodyPair(keyValueMapSerializer, toSet), + Pair(keyValueMapSerializer, toSet), Unit.serializer(), ) }