文件夹是用于协助整理文档的一个属性,它不同于分类的定义。
只有K吧才有文件夹的概念,每个K吧可构建自己的文件夹树去放置文档,而全局知识库可理解成有且只有一个文件夹(因此不可创建)。
GET https://lxapi.lexiangla.com/cgi-bin/v1/directories?directory_id={directory_id}&team_id={team_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
directory_id | 否 | 无 | 文件夹id,不指定时默认为K吧根目录,接口返回该文件夹下的子文件夹 |
team_id | 是 | 无 | K吧id |
document
{
"data": [
{
"type": "directory",
"id": "df20bd06831611e7b3719a23ffd8621b",
"attributes": {
"name": "事故分析",
"weight":0
}
},
{
"type": "directory",
"id": "df23b628831611e79680a56a61f29217",
"attributes": {
"name": "案例分析",
"weight":0
}
},
{
"type": "directory",
"id": "df241e1a831611e7a341e8203947a597",
"attributes": {
"name": "用户体验",
"weight":0
}
},
{
"type": "directory",
"id": "df24acd6831611e7a11256d6e4332b2a",
"attributes": {
"name": "会议纪要",
"weight":0
}
},
{
"type": "directory",
"id": "f211ea30e11d11eabdc50242ac150006",
"attributes": {
"name": "a",
"weight":0
}
},
{
"type": "directory",
"id": "f62db6b2e11d11eaa18c0242ac150006",
"attributes": {
"name": "b",
"weight":0
}
},
{
"type": "directory",
"id": "f9d5bac6e11d11eaaad10242ac150006",
"attributes": {
"name": "c",
"weight":0
}
}
],
"links": {
"first": "http://lxapi.lexiangla.com/cgi-bin/v1/directories?team_id=df1eb1aa831611e78643e529bd527cf3&page=1",
"last": "http://lxapi.lexiangla.com/cgi-bin/v1/directories?team_id=df1eb1aa831611e78643e529bd527cf3&page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://lxapi.lexiangla.com/cgi-bin/v1/directories",
"per_page": 20,
"to": 7,
"total": 7
}
}
{
"errors": [
{
"detail": "{\"team_id\":[\"team id 是无效的.\"]}"
}
]
}
POST https://lxapi.lexiangla.com/cgi-bin/v1/directories
document
{
"data": {
"type": "directory",
"attributes": {
"name": "开放接口创建的文件夹",
"weight":-999
},
"relationships": {
"team": {
"data": {
"type": "team",
"id": "32a8260cb4cc11e8b44bc3f89d9cfabc"
}
},
"parent": {
"data": {
"type": "directory",
"id": "f1572bcecd3711e8b8ee7fe8c886e03c"
}
}
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
name | 是 | 无 | 文件夹名称 |
weight | 否 | 0 | 用于分类排序,越小越优先展示,范围:-999 ~ 9999 |
team | 是 | 无 | 所属K吧 |
parent | 否 | 无 | 父节点,不传入时默认为K吧第一级目录 |
$attributes = [
'name' => '开放接口创建的文件夹',
'team_id' => '32a8260cb4cc11e8b44bc3f89d9cfabc',
];
$options = [
'weight'=>-999,
'parent_id' => 'f1572bcecd3711e8b8ee7fe8c886e03c'
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postDirectory(StaffID, $attributes, $options);
document
{
"data": {
"type": "directory",
"id": "9a76e154cd3811e8b2b8cfb4fc928df1",
"attributes": {
"name": "开放接口创建的文件夹"
}
}
}
DELETE https://lxapi.lexiangla.com/cgi-bin/v1/directories/{directory_id}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
directory_id | 是 | 无 | 文件夹id |
$Lxapi = new \Lexiangla\Openapi\Api($app_key, $app_secret);
$response = $Lxapi->deleteDirectory('StaffID','ef380b7ca67911e89a9f10e7c61c70fc');
document
[]
{
"errors": {
"detail": "不存在ID为`fab2ec5eefef11e99cb65254009b5a66`的directory资源"
}
}
PATCH https://lxapi.lexiangla.com/cgi-bin/v1/directories/{directory_id}
document
{
"data": {
"type": "directory",
"attributes": {
"name": "API更改文件夹",
"weight": -1
}
}
}
参数 | 是否必须 | 默认值 | 说明 |
---|---|---|---|
directory.name | 是 | 无 | 文件夹名称 |
weight | 否 | 默认为创建时的值 | 用于分类排序,越小越优先展示,范围:-999 ~ 9999 |
$Lxapi = new \Lexiangla\Openapi\Api($app_key, $app_secret);
$attributes = [
'name' => 'API更改文件夹'
'weight'=> -10
];
$response = $Lxapi->patchDirectory('StaffID','ef380b7ca67911e89a9f10e7c61c70fc', $attributes);
document
{
"data": {
"type": "directory",
"id": "c14150406fb711e9a9d25254009b5a66",
"attributes": {
"name": "API更改文件夹",
"weight": -1
}
}
}
{
"errors": {
"detail": "不存在ID为`c14150406fb1e9a9d25254009b5a66`的directory资源"
}
}