stack_overflow_client/answers/mod.rs
1// Example API call https://api.stackexchange.com/docs/answers-on-users#order=desc&sort=activity&ids=4676641&filter=default&site=stackoverflow&run=true
2// Answer model: https://api.stackexchange.com/docs/types/answer
3
4use serde::{Deserialize, Serialize};
5
6use crate::user::User;
7
8/// Represents an answer to a quesetion on one of the Stack Exchange sites.
9/// As on the question page it is possible to fetch the comments on an answer as part of the call; though this is not done by default.
10/// The upvoted, downvoted, and accepted fields are not supported in this initial API implementation but they are available in the StackExchange API.
11/// Docs: https://api.stackexchange.com/docs/types/answer
12///
13/// Example answer:
14/// ```json
15/// {
16/// "owner": {
17/// "account_id": 5947562,
18/// "reputation": 4229,
19/// "user_id": 4676641,
20/// "user_type": "registered",
21/// "profile_image": "https://i.stack.imgur.com/8Pzxd.jpg?s=256&g=1",
22/// "display_name": "cam",
23/// "link": "https://stackoverflow.com/users/4676641/cam"
24/// },
25/// "is_accepted": false,
26/// "score": 1,
27/// "last_activity_date": 1616609814,
28/// "creation_date": 1616609814,
29/// "answer_id": 66786986,
30/// "question_id": 66786311,
31/// "content_license": "CC BY-SA 4.0"
32/// }
33/// ```
34///
35#[derive(Debug, Serialize, Deserialize)]
36pub struct Answer {
37 answer_id: u32,
38 content_license: String,
39 is_accepted: bool,
40 last_activity_date: u32,
41 score: u32,
42 owner: User,
43 question_id: u32,
44 title: Option<String>,
45 body: Option<String>,
46}