jp.nephy.penicillin.models.Moment.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of penicillin Show documentation
Show all versions of penicillin Show documentation
Full-featured Twitter API wrapper for Kotlin.
The newest version!
/*
* The MIT License (MIT)
*
* Copyright (c) 2017-2019 Nephy Project Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
@file:Suppress("UNUSED")
package jp.nephy.penicillin.models
import jp.nephy.jsonkt.JsonObject
import jp.nephy.jsonkt.delegation.*
data class Moment(override val json: JsonObject): PenicillinModel {
private val moment by jsonObject
val id by moment.byString
val title by moment.byString
val description by moment.byString
val url by moment.byString
val isLive by moment.byBoolean("is_live")
val time by moment.byString("time_string")
// val lastPublishTime by moment.byString("last_publish_time")
val subcategory by moment.byString("subcategory_string")
val sensitive by moment.byBoolean
val duration by moment.byString("duration_string")
val canSubscribe by moment.byBoolean("can_subscribe")
val capsuleContentsVersion by moment.byString("capsule_contents_version")
val totalLikes by moment.byInt("total_likes")
val users by moment.byLambda { it.jsonObject.toMap().values.map { json -> User(json.jsonObject) } }
val coverMedia by moment.byModel(key = "cover_media")
val displayStyle by string("display_style")
private val context by jsonObject
private val contectScribeInfo by context.byJsonObject
val momentPosition by contectScribeInfo.byString("moment_position")
val tweets by lambda { it.jsonObject.toMap().values.map { json -> Status(json.jsonObject) } }
val coverFormat by model(key = "cover_format")
val largeFormat by model(key = "large_format")
val thumbnailFormat by model(key = "thumbnail_format")
data class CoverFormat(val parentJson: JsonObject): CommonCoverMedia(parentJson) {
val pageId by string("page_id")
val isPromoted by boolean("is_promoted")
private val linkTitleCard by jsonObject("link_title_card")
val linkUrl by linkTitleCard.byString("url")
val linkDisplayUrl by linkTitleCard.byString("display_url")
val linkVanitySource by linkTitleCard.byString("vanity_source")
val linkTitle by linkTitleCard.byString("title")
}
}