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
use crate::Children;
use crate::Requestable;
use std::convert::Into;

#[derive(Clone, Debug, Default, crate::Object)]
pub struct Principal {
    url: String,
    auth: Option<crate::Authorization>,
}

impl Principal {
    pub fn home(&self) -> crate::Result<crate::Home> {
        let response = self.propfind(
            &self.url,
            r#"
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
  <d:prop>
     <d:displayname />
     <c:calendar-home-set />
  </d:prop>
</d:propfind>
"#,
        )?;

        self.one(
            &response,
            "//d:response[1]//cal:calendar-home-set/d:href/text()",
        )
        .ok_or_else(|| crate::Error::Misc("No home found".to_string()))
    }
}