forked from SLYtiger16/caldavjs-nextcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequests.js
89 lines (82 loc) · 2.18 KB
/
requests.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
let requests = {};
requests.listEvents = function (args) {
let filter = (args.start !== null && args.end !== null) ? `
<c:comp-filter name="VCALENDAR">
<c:comp-filter name="VEVENT">
<c:time-range start="${args.start}" end="${args.end}" />
</c:comp-filter>
</c:comp-filter>` : `<c:comp-filter name="VCALENDAR" />`;
return `
<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<d:getetag />
<c:calendar-data />
</d:prop>
<c:filter>
${filter}
</c:filter>
</c:calendar-query>
`.trim();
}
requests.createCalendar = function (args) {
return `
<?xml version="1.0" encoding="utf-8" ?>
<C:mkcalendar xmlns:D="DAV:"
xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:set>
<D:prop>
<D:displayname>${args.name}</D:displayname>
<C:calendar-description xml:lang="en">${args.description}</C:calendar-description>
<C:supported-calendar-component-set>
<C:comp name="VEVENT"/>
</C:supported-calendar-component-set>
<C:calendar-timezone><![CDATA[${args.data}]]></C:calendar-timezone>
</D:prop>
</D:set>
</C:mkcalendar>
`.trim();
}
requests.principal = function (args) {
return `
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:current-user-principal />
</d:prop>
</d:propfind>
`.trim();
}
requests.calendarHome = function (args) {
return `
<d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<c:calendar-home-set />
</d:prop>
</d:propfind>
`.trim();
}
requests.calendarList = function (args) {
return `
<d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<d:resourcetype />
<d:displayname />
<cs:getctag />
<d:sync-token />
<c:supported-calendar-component-set />
</d:prop>
</d:propfind>
`.trim();
}
requests.getChanges = function (args) {
return `
<?xml version="1.0" encoding="utf-8" ?>
<d:sync-collection xmlns:d="DAV:">
<d:sync-token>${args.syncToken}</d:sync-token>
<d:sync-level>1</d:sync-level>
<d:prop>
<d:getetag/>
</d:prop>
</d:sync-collection>
`.trim();
}
export default requests;