mikkelson / shortcut-php
轻量级(无依赖)的Shortcut.com V3 REST API的PHP封装器
This package is not auto-updated.
Last update: 2024-09-17 13:48:05 UTC
README
这是一个轻量级(无依赖)的Shortcut.com REST版本3 API的PHP封装器。请参阅官方的Shortcut API文档。
安装
使用Composer安装
composer require mikkelson/shortcut-php
在包安装完成后,使用Composer提供的自动加载器。
require __DIR__ . '/vendor/autoload.php';
或者,不使用Composer
下载此仓库并包含Shortcut.php
require_once('src/Shortcut.php');
用法及设置
加载包命名空间。
use Mikkelson\Shortcut;
在调用Shortcut之前,创建一个Shortcut
实例,提供您的Shortcut API令牌,您可以在此处获取。
$token = '213901-dk9AJ-3SOJ-8dj9-KAAa0smsa'; $shortcut = new Shortcut($token);
史诗
获取
获取史诗会返回所选史诗的信息。
$epic_id = '3000'; $epic = $shortcut->get('epics', $epic_id);
更新
更新史诗可以用来更新史诗中的多个字段。请参阅可用的字段完整列表。
$epic_id = "4351"; $data = [ 'description' => 'Keep your developers happy by providing detailed descriptions (-;', 'state' => 'to do' ]; $update = $shortcut->update('epics', $epic_id, $data);
删除
删除一个史诗
$epic_id = '3000'; $shortcut->delete('epics', $epic_id);
列表
列出史诗会返回所有史诗及其属性。
$epics = $shortcut->get('epics');
创建
创建史诗允许你在Shortcut中创建一个新的史诗。请参阅可用的字段完整列表。
$new_epic = [ 'deadline' => '2020-08-16T12:30:00Z', 'name' => 'Terraforming of Mars', 'description' => 'Should be easy. Couple of astropeople, a trowel each. Easy.' ]; $epic = $shortcut->create('epics', $new_epic);
文件
获取
获取文件会返回所选文件的信息。
$file_id = '3000'; $file = $shortcut->get('files', $file_id);
更新
更新文件可以用来更新上传到Shortcut的文件的属性。请参阅可用的字段完整列表。
$file_id = "4351"; $data = [ 'description' => 'This file contains all of my most important passwords, in plain text.', 'name' => 'Paswords.txt' ]; $update = $shortcut->update('files', $file_id, $data);
删除
删除文件可以用来删除任何先前附加的文件。
$file_id = '3000'; $shortcut->delete('files', $file_id);
列表
列出文件会返回所有文件及其相关属性。
$files = $shortcut->get('files');
标签
创建
创建标签允许你在Shortcut中创建一个新的标签。
$new_label = [ 'external_id' => 'thirdparty-id-123', 'name' => 'My New Label' ]; $label = $shortcut->create('labels', $new_label);
更新
更新标签允许你用另一个名称替换标签名称。如果你尝试命名一个已经存在的标签,你将收到422响应。
$label_id = "1234"; $data = [ 'name' => 'Updated Label Name' ]; $label = $shortcut->update('labels', $label_id, $data);
删除
删除标签可以用来删除任何标签。
$label_id = '3000'; $shortcut->delete('labels', $label_id);
列表
列出标签会返回所有标签及其属性。
$labels = $shortcut->get('labels');
链接文件
获取
获取文件会返回所选链接文件的信息。
$link_id = 5000; $linked_files = $shortcut->get('linked-files', $link_id);
创建
创建链接文件允许你在Shortcut中创建一个新的链接文件。请参阅可用的字段完整列表
$new_link = [ 'name' => 'My Linked File', 'description' => 'Description of the file', 'type' => 'dropbox', 'url' => 'http://dropbox.com/1sjsSA9Q/asd20j.txt ]; $linked_file = $shortcut->create('linked-files', $new_link);
更新
更新链接文件允许你更新先前附加的链接文件的属性。请参阅可用的字段完整列表
$link_id = "1234"; $data = [ 'name' => 'New name for linked file', 'description' => 'Description of new linked file' ]; $linked_file = $shortcut->update('linked-files', $link_id, $data);
删除
删除链接文件可以用来删除任何先前附加的链接文件。
$link_id = '3000'; $shortcut->delete('linked-files', $link_id);
列表
列出链接文件会返回所有链接文件及其属性。
$linked_files = $shortcut->get('linked-files');
项目
获取
获取项目会返回所选项目的信息。
$project_id = '2990'; $project = $shortcut->get('projects', $project_id);
创建
创建项目用于创建一个新的Shortcut项目。请参阅可用的字段完整列表
$new_project = [ 'name' => 'New Shortcut Project', 'description' => 'Description of the project', 'abbreviation' => 'ncp' ]; $project = $shortcut->create('projects', $new_project);
更新
更新项目可以用来更改项目的属性。请参阅可用的字段完整列表
$project_id = 1234; $data = [ 'name' => 'New name for project', 'description' => 'Description update text' ]; $project = $shortcut->update('projects', $project_id, $data);
删除
“删除项目”功能可以用于删除项目。只有当所有关联的故事被移动或删除后,项目才能被删除。如果项目无法删除,您将收到一个422响应。
$project_id = 3000; $shortcut->delete('projects', $project_id);
列表
“列出项目”返回所有项目及其属性列表。
$projects = $shortcut->get('projects');
故事链接
创建
故事链接允许您在两个故事之间创建语义关系。关系类型包括“相关于”、“阻塞/被阻塞”和“重复/被重复”。格式为“主题 -> 链接 -> 对象”,例如“故事5阻塞故事6”。请参阅可用字段完整列表
$new_link = [ 'object_id' => 100, 'subject_id' => 250, 'verb' => 'blocks' //blocks, relates, duplicates ]; $story_links = $shortcut->create('story-links', $new_link);
获取
返回所选故事链接的信息。
$storylink_id = 3000; $story_links = $shortcut->get('story-links', $storylink_id);
删除
“删除故事链接”功能可以用于删除任何故事链接。
$storylink_id = 3000; $shortcut->delete('story-links', $storylink_id);
故事
搜索
警告 在V3版本中,搜索功能已更改,并且此库尚未完全更新,以下是在此仓库中搜索的临时方法。
“搜索故事”允许您根据所需参数搜索故事。虽然所有参数都是可选的,但您必须至少包含一个参数才能收到响应。
请参阅可用搜索参数完整列表
例如,要搜索所有具有特定工作流状态的故事
$query = "state:500005001"; $stories = $shortcut->get('search/stories?query='.$query);
创建
“创建故事”功能用于向Shortcut添加新故事。请参阅可用字段完整列表
$new_story = [ 'name' => 'New story with some tasks', 'project_id' => 6, 'story_type' => 'feature', //feature, chore, bug 'description' => 'Fuller descriptions make you more friends.', 'tasks' => [ ['description' => 'Task description 1'], ['description' => 'Task description 2'] ] ]; $story = $shortcut->create('stories', $new_story);
获取
“获取故事”返回所选故事的信息。
$story_id = 2000; $story = $shortcut->get('stories', $story_id);
更新
“更新故事”功能可以用于更改故事的属性。请参阅可用字段完整列表
$story_id = 1234; $data = [ 'epic_id' => 29, 'description' => 'Description update text' ]; $story = $shortcut->update('stories', $story_id, $data);
删除
删除一个故事。
$story_id = 300'; $shortcut->delete('stories', $story_id);
用户
列表
“列出用户”返回组织内用户的信息。
$users = $shortcut->get('users');
获取
返回用户的信息。
$user_id = '4JDaa9k-29d3-40s2-a4dc-a9bsd29sc'; $user = $shortcut->get('users', $user_id);
工作流
列表
“列出工作流”返回包含组织中的单个工作流及其属性的列表。
$workflows = $shortcut->get('workflows');