Pixelcat-App-Android/app/src/main/kotlin/at/connyduck/pixelcat/model/Account.kt

74 lines
2.1 KiB
Kotlin
Raw Normal View History

2020-06-17 19:07:47 +02:00
/*
* Copyright (C) 2020 Conny Duck
*
* This file is part of Pixelcat.
*
* Pixelcat is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pixelcat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-06-12 15:44:45 +02:00
package at.connyduck.pixelcat.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
2020-06-12 19:58:15 +02:00
import java.util.Date
2020-06-12 15:44:45 +02:00
@JsonClass(generateAdapter = true)
data class Account(
val id: String,
@Json(name = "username") val localUsername: String,
@Json(name = "acct") val username: String,
@Json(name = "display_name") val displayName: String,
val note: String,
val url: String,
val avatar: String,
val header: String,
val locked: Boolean = false,
@Json(name = "followers_count") val followersCount: Int,
@Json(name = "following_count") val followingCount: Int,
@Json(name = "statuses_count") val statusesCount: Int,
val source: AccountSource?,
val bot: Boolean,
2020-06-12 19:58:15 +02:00
// val emojis: List<Emoji>, // nullable for backward compatibility
val fields: List<Field>?, // nullable for backward compatibility
2020-06-12 15:44:45 +02:00
val moved: Account?
) {
val name: String
get() = displayName.ifEmpty {
2020-06-12 15:44:45 +02:00
localUsername
}
2020-06-12 15:44:45 +02:00
}
@JsonClass(generateAdapter = true)
data class AccountSource(
2020-09-21 16:38:22 +02:00
val privacy: Status.Visibility,
2020-06-12 19:58:15 +02:00
val sensitive: Boolean,
val note: String,
val fields: List<StringField>?
2020-09-21 16:38:22 +02:00
)
2020-06-12 15:44:45 +02:00
@JsonClass(generateAdapter = true)
2020-06-12 19:58:15 +02:00
data class Field(
val name: String,
2020-09-21 16:38:22 +02:00
val value: String,
2020-06-12 19:58:15 +02:00
@Json(name = "verified_at") val verifiedAt: Date?
2020-09-21 16:38:22 +02:00
)
2020-06-12 15:44:45 +02:00
@JsonClass(generateAdapter = true)
2020-06-12 19:58:15 +02:00
data class StringField(
val name: String,
val value: String
2020-09-21 16:38:22 +02:00
)