webapi/src/main/kotlin/model/Articles.kt
author Da Risk <da_risk@geekorum.com>
Mon, 15 Sep 2025 14:00:07 -0400
changeset 1370 13e39ef920a8
parent 1174 731f6ee517b6
permissions -rw-r--r--
update license headers
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
137
5464f07a306c Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents: 113
diff changeset
     1
/*
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     2
 * Geekttrss is a RSS feed reader application on the Android Platform.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     3
 *
1370
13e39ef920a8 update license headers
Da Risk <da_risk@geekorum.com>
parents: 1174
diff changeset
     4
 * Copyright (C) 2017-2025 by Frederic-Charles Barthelery.
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     5
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     6
 * This file is part of Geekttrss.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     7
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     8
 * Geekttrss is free software: you can redistribute it and/or modify
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     9
 * it under the terms of the GNU General Public License as published by
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    10
 * the Free Software Foundation, either version 3 of the License, or
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    11
 * (at your option) any later version.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    12
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    13
 * Geekttrss is distributed in the hope that it will be useful,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    16
 * GNU General Public License for more details.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    17
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    18
 * You should have received a copy of the GNU General Public License
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    19
 * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    20
 */
754
a138890f66f0 webapi: update dependencies and fix some warnings
Da Risk <da_risk@geekorum.com>
parents: 750
diff changeset
    21
@file:OptIn(ExperimentalSerializationApi::class)
310
bd0611482474 Extract tinyrss web api to a new module "webapi"
Da Risk <da_risk@geekorum.com>
parents: 300
diff changeset
    22
package com.geekorum.ttrss.webapi.model
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    23
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    24
import androidx.annotation.Keep
754
a138890f66f0 webapi: update dependencies and fix some warnings
Da Risk <da_risk@geekorum.com>
parents: 750
diff changeset
    25
import kotlinx.serialization.ExperimentalSerializationApi
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    26
import kotlinx.serialization.SerialName
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    27
import kotlinx.serialization.Serializable
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    28
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    29
/**
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    30
 * The payload gor a getHeadlines request.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    31
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    32
 * It allows to retrieve articles from the Tiny Tiny Rss server.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    33
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    34
@Keep
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    35
@Serializable
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    36
data class GetArticlesRequestPayload(
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    37
    @SerialName("feed_id")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    38
    val feedId: Long,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    39
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    40
    @SerialName("view_mode")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    41
    val viewMode: ViewMode = ViewMode.ALL_ARTICLES,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    42
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    43
    @SerialName("show_content")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    44
    val showContent: Boolean = true,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    45
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    46
    @SerialName("show_excerpt")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    47
    val showExcerpt: Boolean = true,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    48
624
cd636ef89d05 webapi: Allow to request headline attachments
Da Risk <da_risk@geekorum.com>
parents: 611
diff changeset
    49
    @SerialName("include_attachments")
cd636ef89d05 webapi: Allow to request headline attachments
Da Risk <da_risk@geekorum.com>
parents: 611
diff changeset
    50
    val includeAttachments: Boolean = false,
cd636ef89d05 webapi: Allow to request headline attachments
Da Risk <da_risk@geekorum.com>
parents: 611
diff changeset
    51
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    52
    private val skip: Int = 0,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    53
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    54
    @SerialName("since_id")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    55
    val sinceId: Long = 0,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    56
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    57
    val limit: Int = 200,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    58
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    59
    @SerialName("order_by")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    60
    val orderBy: SortOrder = SortOrder.NOTHING
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    61
) : LoggedRequestPayload() {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    62
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    63
    @SerialName("op")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    64
    override val operation = "getHeadlines"
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    65
600
c9d6a339dd04 build: update some androidx dependencies
Da Risk <da_risk@geekorum.com>
parents: 565
diff changeset
    66
    @Serializable
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    67
    enum class ViewMode {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    68
        @SerialName("all_articles")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    69
        ALL_ARTICLES,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    70
        @SerialName("unread")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    71
        UNREAD,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    72
        @SerialName("adaptive")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    73
        ADAPTIVE,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    74
        @SerialName("marked")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    75
        MARKED,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    76
        @SerialName("updated")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    77
        UPDATED
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    78
    }
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    79
600
c9d6a339dd04 build: update some androidx dependencies
Da Risk <da_risk@geekorum.com>
parents: 565
diff changeset
    80
    @Serializable
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    81
    enum class SortOrder {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    82
        @SerialName("title")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    83
        TITLE,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    84
        @SerialName("date_reverse")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    85
        DATE_REVERSE,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    86
        @SerialName("feed_dates")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    87
        FEED_DATES,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    88
        @SerialName("")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    89
        NOTHING
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    90
    }
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    91
}
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    92
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    93
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    94
/**
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    95
 * Request payload to update an Article.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    96
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    97
@Keep
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    98
@Serializable
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    99
data class UpdateArticleRequestPayload(
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   100
    @SerialName("article_ids")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   101
    val articleIds: String,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   102
    val mode: Int,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   103
    val field: Int,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   104
    val data: String? = null
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   105
) : LoggedRequestPayload() {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   106
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   107
    @SerialName("op")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   108
    override val operation = "updateArticle"
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   109
}
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   110
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   111
/**
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   112
 * The response of an update article request.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   113
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   114
@Keep
1135
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   115
@Serializable
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   116
data class UpdateArticleResponsePayload(
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   117
    @SerialName("seq")
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   118
    override val sequence: Int? = null,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   119
    override val status: Int = 0,
1135
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   120
    @Serializable(with = ContentSerializer::class)
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   121
    override val content: BaseContent
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   122
) : ResponsePayload<UpdateArticleResponsePayload.Content>() {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   123
1135
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   124
    val updated: Int
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   125
        get() = typedContent?.updated ?: 0
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   126
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   127
    @Serializable
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   128
    data class Content(
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   129
        val status: String? = null,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   130
        val updated: Int? = null,
1135
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   131
    ): BaseContent
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   132
1135
5dd06d1fbe83 webapi: rework serialization to use Content based polymorphic deserialization
Da Risk <da_risk@geekorum.com>
parents: 943
diff changeset
   133
    object ContentSerializer : BaseContentSerializer(Content.serializer())
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
   134
}