deprecate BodyPair

This commit is contained in:
InsanusMokrassar 2022-06-30 13:15:19 +06:00
parent 8250a2a021
commit d4c5e849bf
5 changed files with 23 additions and 18 deletions

View File

@ -2,6 +2,10 @@
## 0.11.11 ## 0.11.11
* `Ktor`:
* `Client`:
* `BodyPair` has been deprecated
## 0.11.10 ## 0.11.10
* `Repos`: * `Repos`:

View File

@ -12,6 +12,7 @@ import io.ktor.http.*
import io.ktor.utils.io.core.ByteReadPacket import io.ktor.utils.io.core.ByteReadPacket
import kotlinx.serialization.* import kotlinx.serialization.*
@Deprecated("This class will be removed in next")
typealias BodyPair<T> = Pair<SerializationStrategy<T>, T> typealias BodyPair<T> = Pair<SerializationStrategy<T>, T>
class UnifiedRequester( class UnifiedRequester(
@ -33,7 +34,7 @@ class UnifiedRequester(
suspend fun <BodyType, ResultType> unipost( suspend fun <BodyType, ResultType> unipost(
url: String, url: String,
bodyInfo: BodyPair<BodyType>, bodyInfo: Pair<SerializationStrategy<BodyType>, BodyType>,
resultDeserializer: DeserializationStrategy<ResultType> resultDeserializer: DeserializationStrategy<ResultType>
) = client.unipost(url, bodyInfo, resultDeserializer, serialFormat) ) = client.unipost(url, bodyInfo, resultDeserializer, serialFormat)
@ -52,7 +53,7 @@ class UnifiedRequester(
url: String, url: String,
filename: String, filename: String,
inputProvider: InputProvider, inputProvider: InputProvider,
otherData: BodyPair<BodyType>, otherData: Pair<SerializationStrategy<BodyType>, BodyType>,
resultDeserializer: DeserializationStrategy<ResultType>, resultDeserializer: DeserializationStrategy<ResultType>,
mimetype: String = "*/*", mimetype: String = "*/*",
additionalParametersBuilder: FormBuilder.() -> Unit = {}, additionalParametersBuilder: FormBuilder.() -> Unit = {},
@ -75,7 +76,7 @@ class UnifiedRequester(
suspend fun <BodyType, ResultType> unimultipart( suspend fun <BodyType, ResultType> unimultipart(
url: String, url: String,
mppFile: MPPFile, mppFile: MPPFile,
otherData: BodyPair<BodyType>, otherData: Pair<SerializationStrategy<BodyType>, BodyType>,
resultDeserializer: DeserializationStrategy<ResultType>, resultDeserializer: DeserializationStrategy<ResultType>,
mimetype: String = "*/*", mimetype: String = "*/*",
additionalParametersBuilder: FormBuilder.() -> Unit = {}, additionalParametersBuilder: FormBuilder.() -> Unit = {},
@ -120,7 +121,7 @@ fun <T> SerializationStrategy<T>.encodeUrlQueryValue(
suspend fun <BodyType, ResultType> HttpClient.unipost( suspend fun <BodyType, ResultType> HttpClient.unipost(
url: String, url: String,
bodyInfo: BodyPair<BodyType>, bodyInfo: Pair<SerializationStrategy<BodyType>, BodyType>,
resultDeserializer: DeserializationStrategy<ResultType>, resultDeserializer: DeserializationStrategy<ResultType>,
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat
) = post(url) { ) = post(url) {
@ -162,7 +163,7 @@ suspend fun <ResultType> HttpClient.unimultipart(
suspend fun <BodyType, ResultType> HttpClient.unimultipart( suspend fun <BodyType, ResultType> HttpClient.unimultipart(
url: String, url: String,
filename: String, filename: String,
otherData: BodyPair<BodyType>, otherData: Pair<SerializationStrategy<BodyType>, BodyType>,
inputProvider: InputProvider, inputProvider: InputProvider,
resultDeserializer: DeserializationStrategy<ResultType>, resultDeserializer: DeserializationStrategy<ResultType>,
mimetype: String = "*/*", mimetype: String = "*/*",
@ -220,7 +221,7 @@ suspend fun <ResultType> HttpClient.unimultipart(
suspend fun <BodyType, ResultType> HttpClient.unimultipart( suspend fun <BodyType, ResultType> HttpClient.unimultipart(
url: String, url: String,
mppFile: MPPFile, mppFile: MPPFile,
otherData: BodyPair<BodyType>, otherData: Pair<SerializationStrategy<BodyType>, BodyType>,
resultDeserializer: DeserializationStrategy<ResultType>, resultDeserializer: DeserializationStrategy<ResultType>,
mimetype: String = "*/*", mimetype: String = "*/*",
additionalParametersBuilder: FormBuilder.() -> Unit = {}, additionalParametersBuilder: FormBuilder.() -> Unit = {},

View File

@ -56,25 +56,25 @@ class KtorWriteStandardCrudRepo<ObjectType, IdType, InputValue> (
override suspend fun create(values: List<InputValue>): List<ObjectType> = unifiedRequester.unipost( override suspend fun create(values: List<InputValue>): List<ObjectType> = unifiedRequester.unipost(
buildStandardUrl(baseUrl, createRouting), buildStandardUrl(baseUrl, createRouting),
BodyPair(listInputSerializer, values), Pair(listInputSerializer, values),
listObjectsSerializer listObjectsSerializer
) )
override suspend fun update(id: IdType, value: InputValue): ObjectType? = unifiedRequester.unipost( override suspend fun update(id: IdType, value: InputValue): ObjectType? = unifiedRequester.unipost(
buildStandardUrl(baseUrl, updateRouting), buildStandardUrl(baseUrl, updateRouting),
BodyPair(inputUpdateSerializer, id to value), Pair(inputUpdateSerializer, id to value),
objectsNullableSerializer objectsNullableSerializer
) )
override suspend fun update(values: List<UpdatedValuePair<IdType, InputValue>>): List<ObjectType> = unifiedRequester.unipost( override suspend fun update(values: List<UpdatedValuePair<IdType, InputValue>>): List<ObjectType> = unifiedRequester.unipost(
buildStandardUrl(baseUrl, updateManyRouting), buildStandardUrl(baseUrl, updateManyRouting),
BodyPair(listInputUpdateSerializer, values), Pair(listInputUpdateSerializer, values),
listObjectsSerializer listObjectsSerializer
) )
override suspend fun deleteById(ids: List<IdType>) = unifiedRequester.unipost( override suspend fun deleteById(ids: List<IdType>) = unifiedRequester.unipost(
buildStandardUrl(baseUrl, deleteByIdRouting), buildStandardUrl(baseUrl, deleteByIdRouting),
BodyPair(listIdsSerializer, ids), Pair(listIdsSerializer, ids),
Unit.serializer() Unit.serializer()
) )
} }

View File

@ -45,7 +45,7 @@ class KtorWriteStandardKeyValueRepo<K, V> (
baseUrl, baseUrl,
setRoute setRoute
), ),
BodyPair(keyValueMapSerializer, toSet), Pair(keyValueMapSerializer, toSet),
Unit.serializer() Unit.serializer()
) )
@ -54,7 +54,7 @@ class KtorWriteStandardKeyValueRepo<K, V> (
baseUrl, baseUrl,
unsetRoute, unsetRoute,
), ),
BodyPair(keysListSerializer, toUnset), Pair(keysListSerializer, toUnset),
Unit.serializer() Unit.serializer()
) )
@ -63,7 +63,7 @@ class KtorWriteStandardKeyValueRepo<K, V> (
baseUrl, baseUrl,
unsetWithValuesRoute, unsetWithValuesRoute,
), ),
BodyPair(valuesListSerializer, toUnset), Pair(valuesListSerializer, toUnset),
Unit.serializer() Unit.serializer()
) )
} }

View File

@ -47,7 +47,7 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
baseUrl, baseUrl,
removeRoute, removeRoute,
), ),
BodyPair(keyValueMapSerializer, toRemove), Pair(keyValueMapSerializer, toRemove),
Unit.serializer(), Unit.serializer(),
) )
@ -56,7 +56,7 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
baseUrl, baseUrl,
addRoute, addRoute,
), ),
BodyPair(keyValueMapSerializer, toAdd), Pair(keyValueMapSerializer, toAdd),
Unit.serializer(), Unit.serializer(),
) )
override suspend fun clear(k: Key) = unifiedRequester.unipost( override suspend fun clear(k: Key) = unifiedRequester.unipost(
@ -64,7 +64,7 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
baseUrl, baseUrl,
clearRoute, clearRoute,
), ),
BodyPair(keySerializer, k), Pair(keySerializer, k),
Unit.serializer(), Unit.serializer(),
) )
@ -73,7 +73,7 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
baseUrl, baseUrl,
clearWithValueRoute, clearWithValueRoute,
), ),
BodyPair(valueSerializer, v), Pair(valueSerializer, v),
Unit.serializer(), Unit.serializer(),
) )
@ -82,7 +82,7 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
baseUrl, baseUrl,
setRoute, setRoute,
), ),
BodyPair(keyValueMapSerializer, toSet), Pair(keyValueMapSerializer, toSet),
Unit.serializer(), Unit.serializer(),
) )
} }