Skip to content

Instantly share code, notes, and snippets.

@MkhytarMkhoian
Created April 18, 2024 13:17
Show Gist options
  • Save MkhytarMkhoian/5698243d48b5b87e80ae63ee6a6ca495 to your computer and use it in GitHub Desktop.
Save MkhytarMkhoian/5698243d48b5b87e80ae63ee6a6ca495 to your computer and use it in GitHub Desktop.
@JsonClass(generateAdapter = true)
data class CategoryDTO(
@Json(name = "id") val id: Long,
@Json(name = "image") val image: String? = null,
@Json(name = "children") val children: List<CategoryDTO>,
@Json(name = "name") val name: String,
@Json(name = "ads_count") val adsCount: Int? = null,
@Json(name = "feed_type") val feedType: FeedType? = null,
) {
enum class FeedType(val id: String) : Serializable {
@Json(name = "map")
MAP("map"),
@Json(name = "default")
DEFAULT("default");
companion object {
fun from(id: String): FeedType? {
return when (id) {
MAP.id -> MAP
DEFAULT.id -> DEFAULT
else -> null
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment