blob: 3a0a0fdb8096667c3f02090923648bb4b3137dd0 (
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
|
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
export const getTemplates = async function() {
const response = await axios.get(generateOcsUrl('apps/files/api/v1/templates'))
return response.data.ocs.data
}
/**
* Create a new file from a specified template
*
* @param {string} filePath The new file destination path
* @param {string} templatePath The template source path
* @param {string} templateType The template type e.g 'user'
* @param {object} templateFields The template fields to fill in (if any)
*/
export const createFromTemplate = async function(filePath, templatePath, templateType, templateFields) {
const response = await axios.post(generateOcsUrl('apps/files/api/v1/templates/create'), {
filePath,
templatePath,
templateType,
templateFields,
})
return response.data.ocs.data
}
|