# K吧

# 创建K吧

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/v1/teams

# 请求document

{
    "data": {
        "type": "team", 
        "attributes": {
            "name": "通过开放接口创建的K吧", 
            "signature": "这是通过开放接口创建的K吧", 
            "type": 1, 
            "logo": null,
            "is_secret": 0,
            "application": ["knowledge", "liveroom"]
        }, 
        "relationships": {
            "category": {
                "data": {
                    "type": "category", 
                    "id": "913fa128fbd711ea9bcf22f21195fed5"
                }
            }, 
            "orgs": {
                "data": [
                    {
                        "type": "staff", 
                        "id": "ThreeZhang"
                    }, 
                    {
                        "type": "department", 
                        "id": 1
                    }
                ]
            }
        }
    }
}

# 参数说明:

参数 是否必须 默认值 说明
data.attributes.name K吧名称
data.attributes.signature null K吧介绍
data.attributes.type 1 K吧应用场景类型;1:自定义;2:知识沉淀;3:项目管理;4:协会培训
data.attributes.logo null k吧封面
data.attributes.is_secret 0 是否保密K吧
data.attributes.application ["knowledge", "event", "album", "survey", "roadmap"] 需要开启的应用, knowledge: 文档, event: 活动, album: 相册, survey: 问卷, exam: 考试, course: 课堂, liveroom: 直播, share: 轻享, roadmap: 项目, collection: 文集
data.relationships.category 关联的资源对象,类型为 category,表示k吧所属分类
data.relationships.orgs 关联的成员对象,类型为orgs,可传入多个staff,department,contact_tag 对象

# SDK封装方法使用示例:

$attributes = [
    'name' => '通过开放接口创建的K吧',
];
$options = [
    'signature' => '这是通过开放接口创建的K吧',
    'type' => 1,
    'category_id' => 'd9b488f41fd911ea90a95254009b5a66',
    'is_secret' => 0,
    'orgs' => [
        [
            'type' => 'staff',
            'id' => 'ThreeZhang'
        ],
        [
            'type' => 'department',
            'id' => 1
        ]
    ]
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->postTeam(StaffID, $attributes, $options);

# 响应document

# 201 Created 状态码
{
    "data": {
        "type": "team",
        "id": "9588b2a496bb11ebb55c4a77494882b0",
        "attributes": {
            "code": "k100045",
            "name": "通过开放接口创建的K吧",
            "type": 1,
            "signature": "这是通过开放接口创建的K吧",
            "is_secret": 0,
            "application": [
                "liveroom",
                "collection"
            ]
        },
        "relationships": {
            "category": {
                "data": {
                    "type": "category",
                    "id": "913fa128fbd711ea9bcf22f21195fed5"
                }
            }
        }
    },
    "included": [
        {
            "type": "category",
            "id": "913fa128fbd711ea9bcf22f21195fed5",
            "attributes": {
                "name": "团队"
            }
        }
    ]
}

# 响应参数说明:

参数 说明
data.attributes.code K吧code
data.attributes.name K吧名称
data.attributes.type k吧应用场景。知识沉淀:2,项目管理:3,type:4,自定义:1
data.attributes.signature k吧介绍
data.attributes.is_secret 是否保密K吧
data.attributes.application 已开启的应用。 knowledge: 文档, event: 活动, album: 相册, survey: 问卷, exam: 考试, course: 课堂, liveroom: 直播, share: 轻享, roadmap: 项目, collection: 文集
data.relationships.category 关联的资源对象,类型为 category,表示k吧所属分类
data.included.name 分类名称

# 编辑K吧

适用于更新K吧名称、K吧介绍以及对K吧成员的管理;对K吧成员管理时,需要全量覆盖之前的成员信息。

# 接口调用说明:

PATCH https://lxapi.lexiangla.com/cgi-bin/v1/teams/{team_id}

# 请求document

{
    "data": {
        "type": "doc", 
        "attributes": {
            "name": "通过开放接口修改K吧",
            "signature": "这是通过开放接口创建的K吧", 
            "logo":null,
          	"is_secret": 0,
            "application": ["knowledge", "liveroom"]
        }, 
        "relationships": {
            "category": {
                "data": {
                    "type": "category", 
                    "id": "9140212afbd711ea90aa22f21195fed5"
                }
            }, 
            "orgs": {
                "data": [
                    {
                        "type": "staff", 
                        "id": "ThreeZhang"
                    }, 
                    {
                        "type": "staff", 
                        "id": "FourLee"
                    }, 
                    {
                        "type": "staff", 
                        "id": "TwoWang"
                    }, 
                    {
                        "type": "department", 
                        "id": 1
                    }
                ]
            }
        }
    }
}

# SDK封装方法使用示例:

$options = [
    'name' => '通过开放接口修改K吧'
];
$options += [
    'signature' => '通过开放接口修改',
    'category_id' => 'abe2befebb7a11ea8d5c869e31ac5a20',
    'is_secret' => 1,
    'orgs' => [
        [
            'type' => 'staff',
            'id' => 'ThreeZhang'
        ],
        [
            'type' => 'department',
            'id' => 2
        ]
    ]
];
$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->patchTeam($staff_id, $team_id, $options);

# 参数说明:

参数 是否必须 默认值 说明
data.attributes.name 无,不传递则不更新 K吧名称
data.attributes.signature 无,不传递则不更新 K吧介绍
data.attributes.is_secret 无,不传递则不更新 是否保密K吧
data.attributes.logo 无,不传递则不更新 k吧封面
data.attributes.application ["knowledge", "event", "album", "survey", "roadmap"] 需要开启的应用, knowledge: 文档, event: 活动, album: 相册, survey: 问卷, exam: 考试, course: 课堂, liveroom: 直播, share: 轻享, roadmap: 项目, collection: 文集
data.relationships.category 无,不传递则不更新 关联的资源对象,类型为 category,表示k吧所属分类
data.relationships.orgs 无,不传递则不更新 关联的成员对象,类型为orgs,可传入多个staff,department,contact_tag 对象

# 响应document

# 200 状态码
{
    "data": {
        "type": "team",
        "id": "9588b2a496bb11ebb55c4a77494882b0",
        "attributes": {
            "code": "k100045",
            "name": "通过开放接口修改K吧",
            "type": 1,
            "signature": "这是通过开放接口创建的K吧",
            "is_secret": 0,
            "application": [
                "liveroom",
                "collection"
            ]
        },
        "relationships": {
            "category": {
                "data": {
                    "type": "category",
                    "id": "9140212afbd711ea90aa22f21195fed5"
                }
            }
        }
    },
    "included": [
        {
            "type": "category",
            "id": "9140212afbd711ea90aa22f21195fed5",
            "attributes": {
                "name": "活动"
            }
        }
    ]
}
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`17bc1d68daae11e9a58410e7c61c70fc`的team资源"
    }
}

# K吧加入回收站

# 接口调用说明:

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/teams/{team_id}/hide

# 参数说明:

参数 是否必须 默认值 说明
team_id K吧id

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api($app_key, $app_secret);
$response = $Lxapi->hideTeam('StaffID','ef380b7ca67911e89a9f10e7c61c70fc');

# 响应document

# 204 No Content 状态码
[]
# 404 Not Found 状态码
{
    "errors": {
        "detail": "不存在ID为`fab2ec5eefef11e99cb65254009b5a66`的team资源"
    }
}

# 获取K吧列表

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/teams

# 参数说明:

支持分页参数和排序:(通用说明?

支持时间范围过滤

参数 是否必须 默认值 说明
sort -created_at 排序参数,支持created_at顺序或倒序,默认倒序
category_id 指定分类id,支持获取某分类下K吧

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('teams', [
    'page'=> 1,
    'per_page' => 3,
    //'sort' => 'created_at',
]);

# 响应document

# 200 OK 状态码
{
    "data": [
        {
            "type": "team",
            "id": "2f92f3600b5711ef9267e20dc5b5df31",
            "attributes": {
                "type": 1,
                "name": "k吧1",
                "code": "k101668",
                "signature": "这是通过开放接口创建的K吧",
                "is_secret": 0,
                "application": [
                    "knowledge",
                    "liveroom"
                ]
            },
            "links": {
                "platform": "https://km.lexiangla.com/teams/k101668"
            },
            "relationships": {
                "category": {
                    "data": {
                        "type": "category",
                        "id": "d9b488f41fd911ea90a95254009b5a66"
                    }
                }
            }
        },
        {
            "type": "team",
            "id": "28b7f4320b5711ef80a8e20dc5b5df31",
            "attributes": {
                "type": 1,
                "name": "k吧2",
                "code": "k101667",
                "signature": null,
                "is_secret": 0,
                "application": [
                    "knowledge",
                    "event",
                    "album",
                    "survey",
                    "roadmap"
                ]
            },
            "links": {
                "platform": "https://km.lexiangla.com/teams/k101667"
            },
            "relationships": {
                "category": {
                    "data": {
                        "type": "category",
                        "id": "d9b488f41fd911ea90a95254009b5a66"
                    }
                }
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/teams?per_page=2&page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/teams?per_page=2&page=673",
        "prev": null,
        "next": "https://lxapi.lexiangla.com/cgi-bin/v1/teams?per_page=2&page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 673,
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/teams",
        "per_page": 2,
        "to": 2,
        "total": 1346
    },
    "included": [
        {
            "type": "category",
            "id": "d9b488f41fd911ea90a95254009b5a66",
            "attributes": {
                "name": "其他"
            }
        }
    ]
}

# 响应参数说明:

参数 说明
data.attributes.code K吧code
data.attributes.name K吧名称
data.attributes.type k吧应用场景。知识沉淀:2,项目管理:3,type:4,自定义:1
data.attributes.signature k吧介绍
data.attributes.is_secret 是否保密K吧
data.attributes.application 已开启的应用。 knowledge: 文档, event: 活动, album: 相册, survey: 问卷, exam: 考试, course: 课堂, liveroom: 直播, share: 轻享, roadmap: 项目, collection: 文集
data.relationships.category 关联的资源对象,类型为 category,表示k吧所属分类
data[*].links k吧首页url
data.links first:接口请求第一页url,last:接口请求最后一页url,prev:接口请求上一页url,next:接口请第下一页url
data.meta.current_page 当前page页数
data.meta.last_page 最后page页数
data.meta.path 接口请求url(不包含入参)
data.meta.per_page 每一页返回k吧数量
data.meta.total 返回的k吧总数量
data.included[*].attributes.name 分类名称

# 获取单个K吧详情

获取k吧详细信息

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/teams/{team_id}

# 参数说明:

参数 是否必须 默认值 说明
team_id 要获取的K吧id

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get("teams/" . $team_id);

# 响应document

# 200 OK 状态码
{
    "data": {
        "type": "team",
        "id": "9588b2a496bb11ebb55c4a77494882b0",
        "attributes": {
            "code": "k100045",
            "name": "K吧名称",
            "type": 1,
            "logo": "https://image-pub.lexiang-asset.com/company_8d67cf3afbd711ea875622f21195fxxx/assets/2021/05/42ecfb16-b882-11eb-834c-b65e687fea4a.jpg",
            "signature": "",
            "is_secret": 0,
            "application": [
                "liveroom",
                "collection"
            ]
        },
        "links": {
            "platform": "https://km.lexiangla.com/teams/k100045"
        },
        "relationships": {
            "orgs": {
                "data": [
                    {
                        "type": "department",
                        "id": "1"
                    },
                    {
                        "type": "staff",
                        "id": "zhangsan"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "type": "department",
            "id": 1,
            "attributes": {
                "name": "XXX有限公司",
                "order": 1
            }
        },
        {
            "type": "staff",
            "id": "zhangsan",
            "attributes": {
                "name": "张三",
                "english_name": null,
                "organization": "XXX有限公司"
            }
        }
    ]
}

# 响应参数说明:

参数 说明
data.attributes.code K吧code
data.attributes.name K吧名称
data.attributes.type k吧应用场景。知识沉淀:2,项目管理:3,type:4,自定义:1
data.attributes.signature k吧介绍
data.attributes.logo k吧封面
data.attributes.is_secret 是否保密K吧
data.attributes.application 已开启的应用。 knowledge: 文档, event: 活动, album: 相册, survey: 问卷, exam: 考试, course: 课堂, liveroom: 直播, share: 轻享, roadmap: 项目, collection: 文集
data[*].links k吧首页url
data.relationships.category 关联的资源对象,类型为 category,表示k吧所属分类
data.included[0].attributes.id 部门id
data.included[0].attributes.name 部门名称
data.included[0].attributes.order 部门排序
data.included[1].attributes.name 成员姓名
data.included[1].attributes.english_name 成员别名
data.included[1].attributes.organization 成员所在组织架构
# 404 Not Found 状态码
{
    "errors":{
        "detail":"不存在ID为`17bc1d68daae11e9a58410e7c61c70fc`的team资源"
    }
}

# 异步导出单个K吧成员列表

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/v1/teams/{team_id}/export-members    

# 参数说明:

参数 是否必须 默认值 说明
team_id K吧ID

# 响应document

# 200 OK 状态码
{
    "data": {
        "job_id": "c89f9754696c11ed93ede6131df597be"
    },
    "msg": "success",
    "code": 0
}

# 响应参数说明:

参数 说明
job_id 任务ID,可通过查询任务接口查询任务进度,当任务完成时,可通过download_url下载json文件

下载得到的json文件内容示例:

{
    "team_id": "3c06606e537011ed9726469d59bfb163",
    "members": [
        {
            "staff_id": "zhangsan"
        },
        {
            "staff_id": "lisi"
        }
    ]
}

# 响应参数说明:

参数 说明
team_id K吧ID
members K吧成员对象数组
members.*.staff_id K吧成员帐号

# 获取单个成员已加入K吧列表

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/v1/staffs/{staff_id}/teams

# 参数说明:

参数 是否必须 默认值 说明
staff_id 员工帐号

# SDK封装方法使用示例:

$Lxapi = new \Lexiangla\Openapi\Api(AppKey, AppSecret);
$response = $Lxapi->get('staffs/' . $staff_id . '/teams');

# 响应document

# 200 OK 状态码
{
    "data": [
        {
            "type": "team",
            "id": "01a4ee3ced5711ed93c38ad873349722",
            "attributes": {
                "code": "k101429",
                "logo": "//static.lexiang-asset.com/build/img/default@2x-42e4xxx.png",
                "name": "K吧1",
                "type": 2,
                "signature": "",
                "is_secret": 1,
                "application": [
                    "knowledge",
                    "event",
                    "survey",
                    "exam",
                    "course",
                    "liveroom",
                    "share",
                    "roadmap"
                ]
            },
            "links": {
                "platform": "https://km.lexiangla.com/teams/k101429"
            }
        },
        {
            "type": "team",
            "id": "089a04fad53811eaa8b25a6976a028b1",
            "attributes": {
                "code": "k100334",
                "logo": null,
                "name": "k吧2",
                "type": 2,
                "signature": "",
                "is_secret": 1,
                "application": [
                    "knowledge",
                    "event",
                    "survey",
                    "exam",
                    "course",
                    "liveroom"
                ]
            },
            "links": {
                "platform": "https://km.lexiangla.com/teams/k100334"
            }
        }
    ],
    "links": {
        "first": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/zhangsan/teams?per_page=2&page=1",
        "last": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/zhangsan/teams?per_page=2&page=10",
        "prev": null,
        "next": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/zhangsan/teams?per_page=2&page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 10,
        "path": "https://lxapi.lexiangla.com/cgi-bin/v1/staffs/zhangsan/teams",
        "per_page": 2,
        "to": 2,
        "total": 19
    }
}

# 响应参数说明:

参数 说明
data.attributes.code K吧code
data.attributes.logo k吧封面
data.attributes.name K吧名称
data.attributes.type k吧应用场景。知识沉淀:2,项目管理:3,type:4,自定义:1
data.attributes.signature k吧介绍
data.attributes.is_secret 是否保密K吧
data.attributes.application 已开启的应用。 knowledge: 文档, event: 活动, album: 相册, survey: 问卷, exam: 考试, course: 课堂, liveroom: 直播, share: 轻享, roadmap: 项目, collection: 文集
data[*].links k吧首页url
data.links first:接口请求第一页url,last:接口请求最后一页url,prev:接口请求上一页url,next:接口请求下一页url
data.meta.current_page 当前page页数
data.meta.last_page 最后page页数
data.meta.path 接口请求url(不包含入参)
data.meta.per_page 每一页返回k吧数量
data.meta.total 返回的k吧总数量
# 404 Not Found 状态码
{
    "errors": [
        {
            "detail": "请求中包含不存在的StaffID"
        }
    ]
}