update models for better work with new libraries

This commit is contained in:
InsanusMokrassar 2019-04-22 09:54:42 +08:00
parent 671af0517b
commit 653967129a
3 changed files with 3 additions and 19 deletions

View File

@ -7,8 +7,6 @@ import kotlinx.serialization.json.*
@Serializable @Serializable
data class Header( data class Header(
@SerialName("user_id")
val userId: Int,
@SerialName("account_type") @SerialName("account_type")
val accountType: String, val accountType: String,
@SerialName("short_limit") @SerialName("short_limit")
@ -35,7 +33,9 @@ data class Header(
@SerialName("query_image") @SerialName("query_image")
val queryImage: String, // something like "uuid.jpg" val queryImage: String, // something like "uuid.jpg"
@SerialName("results_returned") @SerialName("results_returned")
val resultsCount: Int val resultsCount: Int,
@SerialName("user_id")
val userId: Int? = null
) )
object IndexesSerializer : KSerializer<List<HeaderIndex?>> { object IndexesSerializer : KSerializer<List<HeaderIndex?>> {

View File

@ -1,14 +1,11 @@
package com.github.insanusmokrassar.SauceNaoAPI.models package com.github.insanusmokrassar.SauceNaoAPI.models
import kotlinx.serialization.Optional
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@Serializable @Serializable
data class HeaderIndex( data class HeaderIndex(
val status: Int, val status: Int,
val id: Int, val id: Int,
@Optional
val results: Int = 0, val results: Int = 0,
@Optional
val parent_id: Int? = null val parent_id: Int? = null
) )

View File

@ -2,48 +2,35 @@ package com.github.insanusmokrassar.SauceNaoAPI.models
import com.github.insanusmokrassar.SauceNaoAPI.utils.CommonMultivariantStringSerializer import com.github.insanusmokrassar.SauceNaoAPI.utils.CommonMultivariantStringSerializer
import kotlinx.serialization.* import kotlinx.serialization.*
import kotlinx.serialization.internal.ArrayListSerializer
import kotlinx.serialization.internal.StringSerializer
@Serializable @Serializable
data class ResultData( data class ResultData(
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@SerialName("danbooru_id") @SerialName("danbooru_id")
@Optional
val danbooruId: String? = null, val danbooruId: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@SerialName("gelbooru_id") @SerialName("gelbooru_id")
@Optional
val gelbooruId: String? = null, val gelbooruId: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@SerialName("drawr_id") @SerialName("drawr_id")
@Optional
val drawrId: String? = null, val drawrId: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@SerialName("pixiv_id") @SerialName("pixiv_id")
@Optional
val pixivId: String? = null, val pixivId: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@Optional
val title: String? = null, val title: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@Optional
val creator: String? = null, val creator: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@Optional
val material: String? = null, val material: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@SerialName("member_name") @SerialName("member_name")
@Optional
val memberName: String? = null, val memberName: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@SerialName("member_id") @SerialName("member_id")
@Optional
val memberId: String? = null, val memberId: String? = null,
@Serializable(CommonMultivariantStringSerializer::class) @Serializable(CommonMultivariantStringSerializer::class)
@Optional
val characters: String? = null, val characters: String? = null,
@SerialName("ext_urls") @SerialName("ext_urls")
@Optional
val extUrls: List<String> = emptyList() val extUrls: List<String> = emptyList()
) )