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