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
//! [Ref](https://developers.facebook.com/docs/instagram-basic-display-api/overview#long-lived-access-tokens)

use core::time::Duration;

//
//
//
pub const LONG_LIVED_USER_ACCESS_TOKEN_LIFETIME: Duration = Duration::from_secs(3600 * 24 * 60);
pub const SHORT_LIVED_USER_ACCESS_TOKEN_LIFETIME: Duration = Duration::from_secs(3600);

wrapping_macro::wrapping_string! {
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub struct LongLivedUserAccessToken(String);
}

wrapping_macro::wrapping_string! {
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub struct ShortLivedUserAccessToken(String);
}

wrapping_macro::wrapping_string! {
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub struct UserAccessToken(String);
}

impl From<LongLivedUserAccessToken> for UserAccessToken {
    fn from(t: LongLivedUserAccessToken) -> Self {
        Self(t.into_inner())
    }
}

impl From<&LongLivedUserAccessToken> for UserAccessToken {
    fn from(t: &LongLivedUserAccessToken) -> Self {
        Self(t.inner().into())
    }
}

impl From<ShortLivedUserAccessToken> for UserAccessToken {
    fn from(t: ShortLivedUserAccessToken) -> Self {
        Self(t.into_inner())
    }
}

impl From<&ShortLivedUserAccessToken> for UserAccessToken {
    fn from(t: &ShortLivedUserAccessToken) -> Self {
        Self(t.inner().into())
    }
}