aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/src/service/ExampleEventService.js
blob: a39e3641bd978b1a070db35a62c9bdfcb11d4665 (plain)
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
/**
 * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import { generateUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'

/**
 * Configure the creation of example events on a user's first login.
 *
 * @param {boolean} enable Whether to enable or disable the feature.
 * @return {Promise<void>}
 */
export async function setCreateExampleEvent(enable) {
	const url = generateUrl('/apps/dav/api/exampleEvent/enable')
	await axios.post(url, {
		enable,
	})
}

/**
 * Upload a custom example event.
 *
 * @param {string} ics The ICS data of the event.
 * @return {Promise<void>}
 */
export async function uploadExampleEvent(ics) {
	const url = generateUrl('/apps/dav/api/exampleEvent/event')
	await axios.post(url, {
		ics,
	})
}

/**
 * Delete a previously uploaded custom example event.
 *
 * @return {Promise<void>}
 */
export async function deleteExampleEvent() {
	const url = generateUrl('/apps/dav/api/exampleEvent/event')
	await axios.delete(url)
}