
commonMain.com.algolia.client.model.search.SearchHits.kt Maven / Gradle / Ivy
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.search
import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
/**
* SearchHits
*
* @param hits Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
* @param query Search query.
* @param params URL-encoded string of all search parameters.
*/
@Serializable(SearchHitsSerializer::class)
public data class SearchHits(
/** Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. */
val hits: List,
/** Search query. */
val query: String,
/** URL-encoded string of all search parameters. */
val params: String,
val additionalProperties: Map? = null,
)
internal object SearchHitsSerializer : KSerializer {
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("SearchHits") {
element>("hits")
element("query")
element("params")
}
override fun deserialize(decoder: Decoder): SearchHits {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return SearchHits(
hits = tree.getValue("hits").let { input.json.decodeFromJsonElement(it) },
query = tree.getValue("query").let { input.json.decodeFromJsonElement(it) },
params = tree.getValue("params").let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}
override fun serialize(encoder: Encoder, value: SearchHits) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
put("hits", output.json.encodeToJsonElement(value.hits))
put("query", output.json.encodeToJsonElement(value.query))
put("params", output.json.encodeToJsonElement(value.params))
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy