文档模板
文档内容模版目前仅在某些版本的私有部署中可用。
获取模版列表
接口
GET <SHIMO_API>/templates
鉴权信息
参数 | 说明 |
---|---|
scope | "read" |
参数说明
参数 | 类型 | 默认值 / 必填 | 说明 |
---|---|---|---|
page | number | 1 | 当前页数,从 1 开始。 |
size | number | 30 | 每页返回多少项。 |
order | string | desc | 排序方式,可选 asc 。 |
type | string | 无 | 用于过滤模版支持的类型,可用类型见文件。 |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/templates', {
method: 'GET',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(body => console.log(body.data))
返回示例
[
{
"id": 1,
"type": "sheet/modoc",
"content": "q:p!g@T7$5:4!5k#4:3!i# 0 1 2[\"B:工作表1\",\"C*0\",\"G:MODOC\"]",
"createdAt": "2019-11-11T10:33:42Z",
"updatedAt": "2019-11-11T10:33:42Z"
}
]
获取单个模版
接口
GET <SHIMO_API>/templates/<ID>
鉴权信息
参数 | 说明 |
---|---|
scope | "read" |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/templates/1', {
method: 'GET',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(body => console.log(body.data))
返回示例
{
"id": 1,
"type": "sheet/modoc",
"content": "q:p!g@T7$5:4!5k#4:3!i# 0 1 2[\"B:工作表1\",\"C*0\",\"G:MODOC\"]",
"createdAt": "2019-11-11T10:33:42Z",
"updatedAt": "2019-11-11T10:33:42Z"
}
创建模版
接口
POST <SHIMO_API>/templates
鉴权信息
参数 | 说明 |
---|---|
scope | "write" |
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
type | string | Y | 模版对应的文件类型,可用类型见文件。 |
content | String | Y | 模版内容 |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/templates', {
method: 'POST',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'sheet',
content: 'q:p!g@T7$5:4!5k#4:3!i# 0 1 2["B:工作表1","C*0","G:MODOC"]'
})
})
.then(res => res.json())
.then(body => console.log(body.data))
返回示例
{
"id": 1,
"type": "sheet/modoc",
"content": "q:p!g@T7$5:4!5k#4:3!i# 0 1 2[\"B:工作表1\",\"C*0\",\"G:MODOC\"]",
"createdAt": "2019-11-11T10:33:42Z",
"updatedAt": "2019-11-11T10:33:42Z"
}
删除模版
接口
DELETE <SHIMO_API>/templates/<ID>
鉴权信息
参数 | 说明 |
---|---|
scope | "write" |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/templates/1', {
method: 'POST',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(body => console.log(body.data))
状态码说明
204
操作成功
更新模版
接口
PATCH <SHIMO_API>/templates/<ID>
鉴权信息
参数 | 说明 |
---|---|
scope | "write" |
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
type | string | N | 模版对应的文件类型,可用类型见文件。 |
content | String | N | 模版内容 |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/templates/1', {
method: 'PATCH',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'document',
content: '[[10, "\n", "line:\\"init\\""]]'
})
})
.then(res => res.json())
.then(body => console.log(body.data))
状态码说明
204
操作成功