1// Copyright 2018 Frédéric Guillot. All rights reserved. 2// Use of this source code is governed by the Apache 2.0 3// license that can be found in the LICENSE file. 4 5package client // import "miniflux.app/client" 6 7import ( 8 "fmt" 9 "time" 10) 11 12// Entry statuses. 13const ( 14 EntryStatusUnread = "unread" 15 EntryStatusRead = "read" 16 EntryStatusRemoved = "removed" 17) 18 19// User represents a user in the system. 20type User struct { 21 ID int64 `json:"id"` 22 Username string `json:"username"` 23 Password string `json:"password,omitempty"` 24 IsAdmin bool `json:"is_admin"` 25 Theme string `json:"theme"` 26 Language string `json:"language"` 27 Timezone string `json:"timezone"` 28 EntryDirection string `json:"entry_sorting_direction"` 29 EntryOrder string `json:"entry_sorting_order"` 30 Stylesheet string `json:"stylesheet"` 31 GoogleID string `json:"google_id"` 32 OpenIDConnectID string `json:"openid_connect_id"` 33 EntriesPerPage int `json:"entries_per_page"` 34 KeyboardShortcuts bool `json:"keyboard_shortcuts"` 35 ShowReadingTime bool `json:"show_reading_time"` 36 EntrySwipe bool `json:"entry_swipe"` 37 LastLoginAt *time.Time `json:"last_login_at"` 38 DisplayMode string `json:"display_mode"` 39} 40 41func (u User) String() string { 42 return fmt.Sprintf("#%d - %s (admin=%v)", u.ID, u.Username, u.IsAdmin) 43} 44 45// UserCreationRequest represents the request to create a user. 46type UserCreationRequest struct { 47 Username string `json:"username"` 48 Password string `json:"password"` 49 IsAdmin bool `json:"is_admin"` 50 GoogleID string `json:"google_id"` 51 OpenIDConnectID string `json:"openid_connect_id"` 52} 53 54// UserModificationRequest represents the request to update a user. 55type UserModificationRequest struct { 56 Username *string `json:"username"` 57 Password *string `json:"password"` 58 IsAdmin *bool `json:"is_admin"` 59 Theme *string `json:"theme"` 60 Language *string `json:"language"` 61 Timezone *string `json:"timezone"` 62 EntryDirection *string `json:"entry_sorting_direction"` 63 EntryOrder *string `json:"entry_sorting_order"` 64 Stylesheet *string `json:"stylesheet"` 65 GoogleID *string `json:"google_id"` 66 OpenIDConnectID *string `json:"openid_connect_id"` 67 EntriesPerPage *int `json:"entries_per_page"` 68 KeyboardShortcuts *bool `json:"keyboard_shortcuts"` 69 ShowReadingTime *bool `json:"show_reading_time"` 70 EntrySwipe *bool `json:"entry_swipe"` 71 DisplayMode *string `json:"display_mode"` 72} 73 74// Users represents a list of users. 75type Users []User 76 77// Category represents a feed category. 78type Category struct { 79 ID int64 `json:"id,omitempty"` 80 Title string `json:"title,omitempty"` 81 UserID int64 `json:"user_id,omitempty"` 82} 83 84func (c Category) String() string { 85 return fmt.Sprintf("#%d %s", c.ID, c.Title) 86} 87 88// Categories represents a list of categories. 89type Categories []*Category 90 91// Subscription represents a feed subscription. 92type Subscription struct { 93 Title string `json:"title"` 94 URL string `json:"url"` 95 Type string `json:"type"` 96} 97 98func (s Subscription) String() string { 99 return fmt.Sprintf(`Title="%s", URL="%s", Type="%s"`, s.Title, s.URL, s.Type) 100} 101 102// Subscriptions represents a list of subscriptions. 103type Subscriptions []*Subscription 104 105// Feed represents a Miniflux feed. 106type Feed struct { 107 ID int64 `json:"id"` 108 UserID int64 `json:"user_id"` 109 FeedURL string `json:"feed_url"` 110 SiteURL string `json:"site_url"` 111 Title string `json:"title"` 112 CheckedAt time.Time `json:"checked_at,omitempty"` 113 EtagHeader string `json:"etag_header,omitempty"` 114 LastModifiedHeader string `json:"last_modified_header,omitempty"` 115 ParsingErrorMsg string `json:"parsing_error_message,omitempty"` 116 ParsingErrorCount int `json:"parsing_error_count,omitempty"` 117 Disabled bool `json:"disabled"` 118 IgnoreHTTPCache bool `json:"ignore_http_cache"` 119 AllowSelfSignedCertificates bool `json:"allow_self_signed_certificates"` 120 FetchViaProxy bool `json:"fetch_via_proxy"` 121 ScraperRules string `json:"scraper_rules"` 122 RewriteRules string `json:"rewrite_rules"` 123 BlocklistRules string `json:"blocklist_rules"` 124 KeeplistRules string `json:"keeplist_rules"` 125 Crawler bool `json:"crawler"` 126 UserAgent string `json:"user_agent"` 127 Cookie string `json:"cookie"` 128 Username string `json:"username"` 129 Password string `json:"password"` 130 Category *Category `json:"category,omitempty"` 131 HideGlobally bool `json:"hide_globally"` 132} 133 134// FeedCreationRequest represents the request to create a feed. 135type FeedCreationRequest struct { 136 FeedURL string `json:"feed_url"` 137 CategoryID int64 `json:"category_id"` 138 UserAgent string `json:"user_agent"` 139 Cookie string `json:"cookie"` 140 Username string `json:"username"` 141 Password string `json:"password"` 142 Crawler bool `json:"crawler"` 143 Disabled bool `json:"disabled"` 144 IgnoreHTTPCache bool `json:"ignore_http_cache"` 145 AllowSelfSignedCertificates bool `json:"allow_self_signed_certificates"` 146 FetchViaProxy bool `json:"fetch_via_proxy"` 147 ScraperRules string `json:"scraper_rules"` 148 RewriteRules string `json:"rewrite_rules"` 149 BlocklistRules string `json:"blocklist_rules"` 150 KeeplistRules string `json:"keeplist_rules"` 151 HideGlobally bool `json:"hide_globally"` 152} 153 154// FeedModificationRequest represents the request to update a feed. 155type FeedModificationRequest struct { 156 FeedURL *string `json:"feed_url"` 157 SiteURL *string `json:"site_url"` 158 Title *string `json:"title"` 159 ScraperRules *string `json:"scraper_rules"` 160 RewriteRules *string `json:"rewrite_rules"` 161 BlocklistRules *string `json:"blocklist_rules"` 162 KeeplistRules *string `json:"keeplist_rules"` 163 Crawler *bool `json:"crawler"` 164 UserAgent *string `json:"user_agent"` 165 Cookie *string `json:"cookie"` 166 Username *string `json:"username"` 167 Password *string `json:"password"` 168 CategoryID *int64 `json:"category_id"` 169 Disabled *bool `json:"disabled"` 170 IgnoreHTTPCache *bool `json:"ignore_http_cache"` 171 AllowSelfSignedCertificates *bool `json:"allow_self_signed_certificates"` 172 FetchViaProxy *bool `json:"fetch_via_proxy"` 173 HideGlobally *bool `json:"hide_globally"` 174} 175 176// FeedIcon represents the feed icon. 177type FeedIcon struct { 178 ID int64 `json:"id"` 179 MimeType string `json:"mime_type"` 180 Data string `json:"data"` 181} 182 183// Feeds represents a list of feeds. 184type Feeds []*Feed 185 186// Entry represents a subscription item in the system. 187type Entry struct { 188 ID int64 `json:"id"` 189 UserID int64 `json:"user_id"` 190 FeedID int64 `json:"feed_id"` 191 Status string `json:"status"` 192 Hash string `json:"hash"` 193 Title string `json:"title"` 194 URL string `json:"url"` 195 CommentsURL string `json:"comments_url"` 196 Date time.Time `json:"published_at"` 197 CreatedAt time.Time `json:"created_at"` 198 ChangedAt time.Time `json:"changed_at"` 199 Content string `json:"content"` 200 Author string `json:"author"` 201 ShareCode string `json:"share_code"` 202 Starred bool `json:"starred"` 203 ReadingTime int `json:"reading_time"` 204 Enclosures Enclosures `json:"enclosures,omitempty"` 205 Feed *Feed `json:"feed,omitempty"` 206} 207 208// Entries represents a list of entries. 209type Entries []*Entry 210 211// Enclosure represents an attachment. 212type Enclosure struct { 213 ID int64 `json:"id"` 214 UserID int64 `json:"user_id"` 215 EntryID int64 `json:"entry_id"` 216 URL string `json:"url"` 217 MimeType string `json:"mime_type"` 218 Size int `json:"size"` 219} 220 221// Enclosures represents a list of attachments. 222type Enclosures []*Enclosure 223 224// Filter is used to filter entries. 225type Filter struct { 226 Status string 227 Offset int 228 Limit int 229 Order string 230 Direction string 231 Starred bool 232 Before int64 233 After int64 234 BeforeEntryID int64 235 AfterEntryID int64 236 Search string 237 CategoryID int64 238 FeedID int64 239 Statuses []string 240} 241 242// EntryResultSet represents the response when fetching entries. 243type EntryResultSet struct { 244 Total int `json:"total"` 245 Entries Entries `json:"entries"` 246} 247