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
/// An API response from `/api.php`.
use crate::enums::response_code::ResponseCode;
/// A struct representing the response from the server for the main API.
///
/// Example Response
/// ```json
/// {
/// "response_code": 0,
/// "results": [
/// {
/// ...
/// },
/// ...
/// ]
/// }
/// ```
#[derive(Deserialize, Debug)]
pub struct ApiResponse {
pub response_code: ResponseCode,
pub results: Vec<ApiResult>
}
/// A struct representing a collection of Results of a `ApiResponse`.
///
/// Example Result:
/// ```json
/// {
/// "category": "Entertainment: Music",
/// "type": "multiple",
/// "difficulty": "easy",
/// "question": "The Red Hot Chili Pepper song "Give It Away" is from what album?",
/// "correct_answer": "Blood Sugar Sex Magik",
/// "incorrect_answers": [
/// "One Hot Minute",
/// "By the Way",
/// "Stadium Arcadium"
/// ]
/// }
/// ```
/// If a type = "boolean", incorrect_answers will only fill a single slot.
#[derive(Deserialize, Debug)]
pub struct ApiResult {
pub category: String,
#[serde(rename = "type")]
pub question_type: String,
pub difficulty: String,
pub question: String,
pub correct_answer: String,
pub incorrect_answers: Vec<String>
}
/// A struct representing the response of a new Session being created.
///
/// Example Result:
/// ```json
/// {
/// "response_code": 0,
/// "response_message": "Token Generated Successfully!",
/// "token": "2ef34d9dd5a8fd73312fc9ab4cc5a3a1ef392bf751d9ef74216fd55dbd1e6025"
/// }
/// ```
#[derive(Deserialize, Debug)]
pub struct ApiSessionNew {
pub response_code: ResponseCode,
pub response_message: String,
pub token: String
}
/// A struct representing the response of a Session being reset.
///
/// Example Result:
/// ```json
/// {
/// "response_code": 0,
/// "token": "2ef34d9dd5a8fd73312fc9ab4cc5a3a1ef392bf751d9ef74216fd55dbd1e6025"
/// }
/// ```
#[derive(Deserialize, Debug)]
pub struct ApiSessionReset {
pub response_code: ResponseCode,
pub token: String
}