mirror of
https://github.com/InsanusMokrassar/SauceNaoAPI.git
synced 2024-12-23 05:07:12 +00:00
hotfix for SauceNaoAnswer serializer
This commit is contained in:
parent
d5d3de9559
commit
ea9d76fa47
@ -12,6 +12,10 @@
|
||||
* Now `SauceNaoAPI` working with synchronous queue
|
||||
* `SauceNaoAPI` now will wait for some time when one of limits will be achieved
|
||||
|
||||
### 0.4.3
|
||||
|
||||
Hotfix for serializer of `SauceNaoAnswer`
|
||||
|
||||
### 0.4.2
|
||||
|
||||
Hotfix for autostop for some time when there is no remaining quotas for requests
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.4.2"
|
||||
project.version = "0.4.3"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
|
@ -5,6 +5,7 @@ import com.github.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATI
|
||||
import com.github.insanusmokrassar.SauceNaoAPI.exceptions.TooManyRequestsException
|
||||
import com.github.insanusmokrassar.SauceNaoAPI.exceptions.sauceNaoAPIException
|
||||
import com.github.insanusmokrassar.SauceNaoAPI.models.SauceNaoAnswer
|
||||
import com.github.insanusmokrassar.SauceNaoAPI.models.SauceNaoAnswerSerializer
|
||||
import com.github.insanusmokrassar.SauceNaoAPI.utils.*
|
||||
import com.github.insanusmokrassar.SauceNaoAPI.utils.calculateSleepTime
|
||||
import io.ktor.client.HttpClient
|
||||
@ -122,7 +123,7 @@ data class SauceNaoAPI(
|
||||
logger.info(answerText)
|
||||
timeManager.addTimeAndClear()
|
||||
Json.nonstrict.parse(
|
||||
SauceNaoAnswer.serializer(),
|
||||
SauceNaoAnswerSerializer,
|
||||
answerText
|
||||
)
|
||||
} catch (e: ClientRequestException) {
|
||||
|
@ -4,11 +4,11 @@ import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.ArrayListSerializer
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
@Serializable(SauceNaoAnswerSerializer::class)
|
||||
data class SauceNaoAnswer(
|
||||
@Serializable
|
||||
data class SauceNaoAnswer internal constructor(
|
||||
val header: Header,
|
||||
val results: List<Result> = emptyList(),
|
||||
val raw: JsonObject
|
||||
val raw: JsonObject = JsonObject(emptyMap())
|
||||
)
|
||||
|
||||
@Serializer(SauceNaoAnswer::class)
|
||||
@ -20,10 +20,14 @@ object SauceNaoAnswerSerializer : KSerializer<SauceNaoAnswer> {
|
||||
|
||||
override fun deserialize(decoder: Decoder): SauceNaoAnswer {
|
||||
val raw = JsonObjectSerializer.deserialize(decoder)
|
||||
val header = serializer.fromJson(Header.serializer(), raw.getObject(headerField))
|
||||
val results = serializer.fromJson(resultsSerializer, raw.getArray(resultsField))
|
||||
val stringRaw = serializer.stringify(JsonObjectSerializer, raw)
|
||||
|
||||
return SauceNaoAnswer(header, results, raw)
|
||||
return serializer.parse(
|
||||
SauceNaoAnswer.serializer(),
|
||||
stringRaw
|
||||
).copy(
|
||||
raw = raw
|
||||
)
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, obj: SauceNaoAnswer) {
|
||||
|
Loading…
Reference in New Issue
Block a user