aklump/ taskcamp_api
定义了一个通用的API,用于处理In the Loft Studios开发的Taskcamp项目管理系统的操作。
0.3.1
2024-03-18 22:24 UTC
Requires
- php: ^8
- ext-dom: *
- ext-simplexml: *
- symfony/property-access: ^6
- symfony/serializer: ^6
- symfony/yaml: ^6
Requires (Dev)
- aklump/phpswap: ^0.0.7
- phpunit/phpunit: ^9.5
README
摘要
这是Taskcamp的核心API库,由In the Loft Studios提供。它应该被希望与该应用程序一起工作的API客户端使用。
核心上,它定义了一种新的序列化格式,这是一种HTML、YAML和markdown的组合,用于表示复杂的数据关系,如下所示。更多信息请参见此页面。
相应的MIME类型是:application/prs.taskcamp.entity
。
<type property="123"/>
---
attribute: value
---
# title
body
PHP
安装
composer require aklump/taskcamp_api
使用
反序列化
下面是一个\AKlump\Taskcamp\API\Entity
的JSON表示示例
{
"type": "bug",
"properties": {
"projectName": "My Project",
"projectId": 123
},
"data": {
"device": "mac",
"os": {
"name": "macosx",
"version": "10.13.6"
}
},
"title": "The title has too much top margin",
"body": ""
}
以下是如何反序列化一个JSON字符串,如上面的示例所示。
use AKlump\Taskcamp\API\Entity;
use AKlump\Taskcamp\API\EntityEncoder;
use AKlump\Taskcamp\API\EntitySerializer;
$serializer = new EntitySerializer();
$entity = $serializer->deserialize($json, Entity::class, 'json');
如果数据以其他格式编码,您可以使用以下任何一个
$entity = $serializer->deserialize($entity_markup, Entity::class, EntityEncoder::TYPE);
$entity = $serializer->deserialize($xml, Entity::class, 'xml');
序列化
以下是如何将对象序列化为EntityEncoder::TYPE
格式的方法。
$entity = new Entity();
$entity
->setType('feature')
->setTitle('Augment the footer with another section')
->setBody('In order to fit in the about section in the footer, we need to create a fourth column that can take a custom block. The block needs to be added to the region so the client can edit it.')
->setProperties(['projectId' => 123])
->setData(['priority' => 'high']);
$markup = $serializer->serialize($entity, EntityEncoder::TYPE);
以下是该格式的样子
<feature projectId="123"/>
---
priority: high
---
# Augment the footer with another section
In order to fit in the about section in the footer, we need to create a fourth column that can take a custom block. The block needs to be added to the region so the client can edit it.
Javascript
@待办
安装
yarn add @aklump/taskcamp_api
或者如果不使用yarn
npm install @aklump/taskcamp_api