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
/// Builder struct for defining your application.
/// ```
/// let app = AppBuilder {
///     client_name: "mammut_test",
///     redirect_uris: "urn:ietf:wg:oauth:2.0:oob",
///     scopes: Scope::Read,
///     website: None,
/// };
/// ```
#[derive(Debug, Default, Serialize)]
pub struct AppBuilder<'a> {
    pub client_name: &'a str,
    pub redirect_uris: &'a str,
    pub scopes: Scope,
    #[serde(skip_serializing_if="Option::is_none")]
    pub website: Option<&'a str>,
}

#[derive(Debug, Clone, Copy, Serialize)]
pub enum Scope {
    /// All Permissions, equiavlent to `read write follow`
    #[serde(rename = "read write follow")]
    All,
    /// Only permission to add and remove followers.
    #[serde(rename = "follow")]
    Follow,
    /// Read only permissions.
    #[serde(rename = "read")]
    Read,
    #[serde(rename = "read follow")]
    ReadFollow,
    #[serde(rename = "read write")]
    ReadWrite,
    #[serde(rename = "write")]
    Write,
    #[serde(rename = "write follow")]
    WriteFollow,
}

impl Default for Scope {
    fn default() -> Self {
        Scope::Read
    }
}