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
use chrono::prelude::{DateTime, Utc};
use std::collections::HashMap as Map;

type Time = DateTime<Utc>;

#[derive(Clone, Debug, Deserialize)]
pub struct Report<T> {
    id:              Option<u32>,
    object:          String,
    url:             String,
    data_updated_at: Time,
    data:            T,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Collection<T> {
    object:          String,
    url:             String,
    data_updated_at: Time,
    pages:           Pages,
    total_count:     u32,
    data:            Vec<T>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Pages {
    per_page:     u32,
    next_url:     Option<String>,
    previous_url: Option<String>
}

#[derive(Clone, Debug, Deserialize)]
pub struct User {
    username:                          String,
    level:                             u8,
    max_level_granted_by_subscription: u8,
    started_at:                        Time,
    subscribed:                        bool,
    current_vacation_started_at:       Option<Time>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Subject {
    level:                 u8,
    created_at:            Time,
    slug:                  String,
    document_url:          String,
    characters:            Option<String>,
    meanings:              Vec<Meaning>,
    character_images:      Option<Vec<Map<String, String>>>, // only radicals
    readings:              Option<Vec<Reading>>,             // only kanji, vocabulary
    parts_of_speech:       Option<Vec<String>>,              // only vocabulary
    component_subject_ids: Option<Vec<u32>>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Meaning {
    meaning: String,
    primary: bool,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Reading {
    #[serde(rename="type")]
    kind:    String,
    primary: bool,
    reading: String,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Assignment {
    created_at:     Time,
    subject_id:     u32,
    subject_type:   String,
    level:          u8,
    srs_stage:      u8,
    srs_stage_name: String,
    unlocked_at:    Option<Time>,
    started_at:     Option<Time>,
    passed_at:      Option<Time>,
    burned_at:      Option<Time>,
    available_at:   Option<Time>,
    resurrected_at: Option<Time>,
    passed:         bool,
    resurrected:    bool,
}

#[derive(Clone, Debug, Deserialize)]
pub struct ReviewStatistic {
    created_at:             Time,
    subject_id:             u32,
    meaning_correct:        u32,
    meaning_incorrect:      u32,
    meaning_max_streak:     u32,
    meaning_current_streak: u32,
    reading_correct:        u32,
    reading_incorrect:      u32,
    reading_max_streak:     u32,
    reading_current_streak: u32,
    percentage_correct:     u32,
}

#[derive(Clone, Debug, Deserialize)]
pub struct StudyMaterial {
    created_at:       Time,
    subject_id:       u32,
    subject_type:     String,
    meaning_note:     Option<String>,
    reading_note:     Option<String>,
    meaning_synonyms: Vec<String>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Summary {
    reviews: Vec<SummaryItem>,
    lessons: Vec<SummaryItem>,
}

#[derive(Clone, Debug, Deserialize)]
struct SummaryItem {
    available_at: Time,
    subject_ids:  Vec<u32>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Review {
    created_at:                Time,
    assignment_id:             u32,
    subject_id:                u32,
    starting_srs_stage:        u32,
    starting_srs_stage_name:   String,
    ending_srs_stage:          u32,
    ending_srs_stage_name:     String,
    incorrect_meaning_answers: Option<u32>,
    incorrect_reading_answers: Option<u32>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct LevelProgression {
    level:        u8,
    created_at:   Time,
    unlocked_at:  Option<Time>,
    started_at:   Option<Time>,
    passed_at:    Option<Time>,
    completed_at: Option<Time>,
    abandoned_at: Option<Time>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Reset {
    created_at:     Time,
    original_level: u8,
    target_level:   u8,
    confirmed_at:   Time,
}