pickcat-api-collection 0.1.7

PickcatAPI合集
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
//! 用户章节及跨章节共享的 DTO。

use serde::{Deserialize, Serialize};

use crate::dto::IdValue;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetUserInformationDTO {
    pub id: String,
    pub username: String,
    pub avatar: UserAvatarDTO,
    pub bio: Option<String>,
    pub region: Option<String>,
    pub show_following_list: bool,
    pub show_followers_list: bool,
    pub created_at: String,
    pub level: UserLevelDTO,
    pub stats: UserStatsDTO,
    pub viewer_state: UserViewerStateDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserAvatarDTO {
    #[serde(rename = "type")]
    pub avatar_type: String,
    pub id: IdValue,
    pub url: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserLevelDTO {
    pub current: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserStatsDTO {
    pub followers: u64,
    pub following: u64,
    pub topics: u64,
    pub replies: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserViewerStateDTO {
    pub following: bool,
    pub can_follow: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetUserEmailDTO {
    pub email: String,
    pub verified_at: String,
}

/// 主题/楼层列表项里的作者:只含 `id`/`username`/`avatar`/`displayedBadge`,
/// 与完整的 `GetUserInformationDTO` 不同。
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TopicAuthorDTO {
    pub id: String,
    pub username: String,
    pub avatar: UserAvatarDTO,
    pub displayed_badge: Option<DisplayedBadgeDTO>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserSubjectInfoDTO {
    pub id: String,
    pub title: String,
    pub kind: String,
    pub excerpt: String,
    pub author: TopicAuthorDTO,
    pub tags: Vec<UserSubjectTagDTO>,
    pub reply_count: u64,
    pub view_count: u64,
    pub like_count: u64,
    pub bookmark_count: u64,
    /// 仅 `kind == "QUESTION"` 时存在,结构未文档化。
    pub question_state: Option<serde_json::Value>,
    pub closed_at: Option<String>,
    pub pinned: bool,
    pub pinned_globally: bool,
    pub pinned_tag_id: Option<String>,
    pub pinned_at: Option<String>,
    pub pinned_until: Option<String>,
    pub created_at: String,
    pub edited_at: Option<String>,
    pub last_activity_at: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserSubjectTagDTO {
    pub id: String,
    pub slug: String,
    pub name: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserSubjectsDTO {
    pub items: Vec<UserSubjectInfoDTO>,
    pub page_info: UserSubjectsPageInfoDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserSubjectsPageInfoDTO {
    pub has_next_page: bool,
    pub next_cursor: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserRepliesDTO {
    pub items: Vec<UserReplyDTO>,
    pub page_info: UserRepliesPageInfoDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserReplyDTO {
    pub id: String,
    pub topic_id: String,
    pub post_number: u64,
    pub reply_to_post_number: Option<u64>,
    pub deleted: bool,
    pub children: Vec<UserReplyDTO>,
    pub current_revision: u64,
    pub like_count: u64,
    pub pinned: bool,
    pub cooked_html: String,
    pub author: TopicAuthorDTO,
    pub created_at: String,
    pub edited_at: Option<String>,
    pub viewer_capabilities: UserReplyViewerCapabilitiesDTO,
    pub viewer_state: UserReplyViewerStateDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserRepliesPageInfoDTO {
    pub has_next_page: bool,
    pub next_cursor: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserReplyViewerCapabilitiesDTO {}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserReplyViewerStateDTO {}

// ---------------------------------------------------------------------------
// 通用游标分页
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PageInfoDTO {
    pub has_next_page: bool,
    pub next_cursor: Option<String>,
}

/// `{ "items": [...], "pageInfo": {...} }` 形式的通用游标分页响应。
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CursorListDTO<T> {
    pub items: Vec<T>,
    pub page_info: PageInfoDTO,
}

// ---------------------------------------------------------------------------
// PATCH /users/{userId}
// ---------------------------------------------------------------------------

/// 只提交需要变更的字段;`None` 的字段不会出现在请求体里。
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateUserProfileDTO {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bio: Option<String>,
}

// ---------------------------------------------------------------------------
// GET /users/{userId}/featured-topics
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserFeaturedTopicsDTO {
    pub items: Vec<UserSubjectInfoDTO>,
}

// ---------------------------------------------------------------------------
// 徽章
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BadgeImageDTO {
    pub file_id: String,
    pub url: String,
    pub width: u64,
    pub height: u64,
}

/// `GET /users/{userId}/badges` 中的完整徽章详情。
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BadgeDTO {
    pub id: String,
    pub slug: String,
    pub name: String,
    pub description: String,
    pub icon: String,
    pub version: u64,
    pub image: BadgeImageDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserBadgeDTO {
    pub user_id: String,
    pub badge_id: String,
    pub granted_at: String,
    pub revision: String,
    pub badge: BadgeDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserBadgesDTO {
    pub items: Vec<UserBadgeDTO>,
}

/// 批量/展示接口里返回的精简徽章对象。
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DisplayedBadgeDTO {
    pub id: String,
    pub name: String,
    pub description: String,
    pub image: BadgeImageDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BadgeDisplayDTO {
    pub mode: String,
    pub badge_id: Option<String>,
    pub displayed_badge: Option<DisplayedBadgeDTO>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserBadgeDisplayItemDTO {
    pub user_id: String,
    pub displayed_badge: Option<DisplayedBadgeDTO>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserBadgeDisplaysDTO {
    pub items: Vec<UserBadgeDisplayItemDTO>,
}

// ---------------------------------------------------------------------------
// 用户动态
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProfileActivityDTO {
    pub id: String,
    /// `POSTED` / `LIKED` / `LEVEL_UP`
    pub kind: String,
    pub occurred_at: String,
    pub title: Option<String>,
    pub level: Option<u64>,
}

// ---------------------------------------------------------------------------
// 贡献日历
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LevelContributionDayDTO {
    pub date: String,
    pub ability: u64,
    pub responsibility: u64,
    pub care: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LevelContributionsDTO {
    pub year: u64,
    pub time_zone: String,
    pub days: Vec<LevelContributionDayDTO>,
    pub updating: bool,
    pub calculated_at: String,
}

// ---------------------------------------------------------------------------
// 等级进度
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LevelScoresDTO {
    pub ability: u64,
    pub responsibility: u64,
    pub care: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LevelFamiliarityDTO {
    pub tracking: bool,
    pub familiarity_started_at: String,
    pub days_since_entrance_exam: u64,
    pub valid_visit_days: u64,
    pub topics_entered: u64,
    pub posts_read: u64,
    pub effective_reading_seconds: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LevelRequirementDTO {
    pub current: u64,
    pub required: u64,
    pub met: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NextLevelScoresDTO {
    pub ability: LevelRequirementDTO,
    pub responsibility: LevelRequirementDTO,
    pub care: LevelRequirementDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NextLevelFamiliarityDTO {
    pub days_since_entrance_exam: LevelRequirementDTO,
    pub valid_visit_days: LevelRequirementDTO,
    pub topics_entered: LevelRequirementDTO,
    pub posts_read: LevelRequirementDTO,
    pub effective_reading_seconds: LevelRequirementDTO,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HardRequirementDTO {
    pub key: String,
    pub met: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NextLevelDTO {
    pub level: u64,
    pub admission: String,
    pub scores: NextLevelScoresDTO,
    pub familiarity: NextLevelFamiliarityDTO,
    pub hard_requirements: Vec<HardRequirementDTO>,
    pub blocked_by_promotion_ceiling: bool,
    pub eligible: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuotaDTO {
    pub action: String,
    pub limit: u64,
    pub used: u64,
    pub remaining: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LevelProgressDTO {
    pub current_level: u64,
    /// 文档中观测为 `null`,类型未验证。
    pub promotion_ceiling: Option<serde_json::Value>,
    pub scores: LevelScoresDTO,
    pub familiarity: LevelFamiliarityDTO,
    pub next_level: Option<NextLevelDTO>,
    pub lv4_candidate: bool,
    pub quotas: Vec<QuotaDTO>,
    pub updating: bool,
    pub calculated_at: String,
}

// ---------------------------------------------------------------------------
// 配额 / 上限
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ContentLengthLimitDTO {
    pub level: u64,
    pub topic_max_length: u64,
    pub reply_max_length: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TopicCollectionUsageDTO {
    pub current_level: u64,
    pub limit_count: u64,
    pub used_count: u64,
    pub remaining_count: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FileStorageDTO {
    pub used_bytes: u64,
    pub limit_bytes: u64,
    pub remaining_bytes: u64,
}

// ---------------------------------------------------------------------------
// 预设头像
// ---------------------------------------------------------------------------

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AvatarPresetDTO {
    #[serde(rename = "type")]
    pub avatar_type: String,
    pub id: IdValue,
    pub url: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AvatarPresetsDTO {
    pub items: Vec<AvatarPresetDTO>,
}