Skip to main content

appwrite/models/
o_auth2_spotify.rs

1//! OAuth2Spotify model for Appwrite SDK
2
3use serde::{Deserialize, Serialize};
4
5/// OAuth2Spotify
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[cfg_attr(test, derive(Default))]
8pub struct OAuth2Spotify {
9    /// OAuth2 provider ID.
10    #[serde(rename = "$id")]
11    pub id: String,
12    /// OAuth2 provider is active and can be used to create sessions.
13    #[serde(rename = "enabled")]
14    pub enabled: bool,
15    /// Spotify OAuth2 client ID.
16    #[serde(rename = "clientId")]
17    pub client_id: String,
18    /// Spotify OAuth2 client secret.
19    #[serde(rename = "clientSecret")]
20    pub client_secret: String,
21}
22
23impl OAuth2Spotify {
24    /// Get id
25    pub fn id(&self) -> &String {
26        &self.id
27    }
28
29    /// Get enabled
30    pub fn enabled(&self) -> &bool {
31        &self.enabled
32    }
33
34    /// Get client_id
35    pub fn client_id(&self) -> &String {
36        &self.client_id
37    }
38
39    /// Get client_secret
40    pub fn client_secret(&self) -> &String {
41        &self.client_secret
42    }
43
44}
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_o_auth2_spotify_creation() {
52        let _model = <OAuth2Spotify as Default>::default();
53        let _ = _model.id();
54        let _ = _model.enabled();
55        let _ = _model.client_id();
56        let _ = _model.client_secret();
57    }
58
59    #[test]
60    fn test_o_auth2_spotify_serialization() {
61        let model = <OAuth2Spotify as Default>::default();
62        let json = serde_json::to_string(&model);
63        assert!(json.is_ok());
64
65        let deserialized: Result<OAuth2Spotify, _> = serde_json::from_str(&json.unwrap());
66        assert!(deserialized.is_ok());
67    }
68}