pcloud/general/
userinfo.rs

1use chrono::{DateTime, Utc};
2
3#[derive(Debug, serde::Serialize, serde::Deserialize)]
4pub struct UserInfo {
5    pub email: String,
6    #[serde(rename = "emailverified")]
7    pub email_verified: bool,
8    #[serde(with = "crate::date")]
9    pub registered: DateTime<Utc>,
10    #[serde(default)]
11    pub premium: bool,
12    #[serde(default, rename = "premiumexpires", with = "crate::date::optional")]
13    pub premium_expires: Option<DateTime<Utc>>,
14    pub quota: u64,
15    #[serde(rename = "usedquota")]
16    pub used_quota: u64,
17    pub language: String,
18}
19
20impl crate::Client {
21    /// Fetches the information about the current user.
22    ///
23    /// # Returns
24    ///
25    /// A [`UserInfo`] struct containing the user information.
26    ///
27    /// # Errors
28    ///
29    /// Returns a [`crate::Error`] if the folder cannot be listed.
30    ///
31    /// # Examples
32    ///
33    /// ```
34    /// # async fn example(client: &pcloud::Client) -> Result<(), pcloud::Error> {
35    /// let info = client.user_info().await?;
36    /// println!("{:?}", info);
37    /// # Ok(())
38    /// # }
39    /// ```
40    pub async fn user_info(&self) -> crate::Result<UserInfo> {
41        self.get_request("userinfo", &()).await
42    }
43}