2023-06-19 17:42:47 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-11-20 00:10:04 -05:00
|
|
|
|
2018-08-25 00:51:50 -04:00
|
|
|
package model // import "miniflux.app/model"
|
2017-11-20 00:10:04 -05:00
|
|
|
|
2021-01-04 01:28:04 -05:00
|
|
|
import "fmt"
|
2017-11-20 00:10:04 -05:00
|
|
|
|
2021-01-04 01:28:04 -05:00
|
|
|
// Category represents a feed category.
|
2017-11-20 00:10:04 -05:00
|
|
|
type Category struct {
|
2021-06-02 20:39:47 -04:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
UserID int64 `json:"user_id"`
|
|
|
|
HideGlobally bool `json:"hide_globally"`
|
2023-06-19 12:50:08 -04:00
|
|
|
FeedCount *int `json:"feed_count,omitempty"`
|
|
|
|
TotalUnread *int `json:"total_unread,omitempty"`
|
2017-11-20 00:10:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Category) String() string {
|
|
|
|
return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
|
|
|
|
}
|
|
|
|
|
2021-01-04 01:28:04 -05:00
|
|
|
// CategoryRequest represents the request to create or update a category.
|
|
|
|
type CategoryRequest struct {
|
2021-06-02 20:39:47 -04:00
|
|
|
Title string `json:"title"`
|
|
|
|
HideGlobally string `json:"hide_globally"`
|
2017-11-20 00:10:04 -05:00
|
|
|
}
|
|
|
|
|
2021-01-04 01:28:04 -05:00
|
|
|
// Patch updates category fields.
|
|
|
|
func (cr *CategoryRequest) Patch(category *Category) {
|
|
|
|
category.Title = cr.Title
|
2021-06-02 20:39:47 -04:00
|
|
|
category.HideGlobally = cr.HideGlobally != ""
|
2017-11-20 00:10:04 -05:00
|
|
|
}
|
|
|
|
|
2017-11-25 22:06:02 -05:00
|
|
|
// Categories represents a list of categories.
|
2017-11-20 00:10:04 -05:00
|
|
|
type Categories []*Category
|