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
#[derive(thiserror::Error, Debug)]
pub enum APIErrorKind {
    #[error("")]
    InternalDatabaseError,
    #[error("Could not find user; uid may be invalid.")]
    AccountNotFound,
    #[error("User's data is not public.")]
    DataNotPublic,
    #[error("Cookies are not valid.")]
    InvalidCookies,
    #[error("Cannot get data for more than 30 accounts per cookie per day.")]
    TooManyRequests,
    #[error("Visits too frequently.")]
    VisitsTooFrequently,
    #[error("Already claimed the daily reward today.")]
    AlreadyClaimed,
    #[error("Geetest triggered during daily reward claim.")]
    GeetestTriggered,
    #[error("Authkey is not valid.")]
    InvalidAuthkey,
    #[error("Authkey has timed out.")]
    AuthkeyTimeout,
    #[error("Invalid redemption code.")]
    RedemptionInvalid,
    #[error("Redemption is on cooldown.")]
    RedemptionCooldown,
    #[error("Redemption code has been claimed already.")]
    RedemptionClaimed,
    #[error("Account login failed.")]
    AccountLoginFail,
    #[error("Account has been locked because exceeded password limit. Please wait 20 minute and try again")]
    AccountHasLocked,
    #[error("unknown data store error")]
    Unknown,
}


pub struct APIException {
    pub retcode: i16,
    pub original: String,
    pub msg: String,
}
impl APIException {
    pub fn response(&self) -> String {
        format!("retcode: {}, message: {}, data: None", self.retcode, self.original)
    }
}