seregazhuk/favro-api

官方Favro API的PHP封装

0.2.4 2018-04-01 13:35 UTC

This package is auto-updated.

Last update: 2024-09-16 03:57:30 UTC


README

Favro PHP Api

依赖关系

库需要CURL扩展和PHP 5.6或更高版本。

安装

安装此库的推荐方法是使用ComposerComposer初学者?

composer require seregazhuk/favro-api

快速开始

首先,您需要选择您当前的组织,因为几乎所有的API请求都需要组织ID,即这些调用针对的组织ID。您可以通过以下两种方式设置当前组织:通过名称或ID。

// You may need to amend this path to locate composer's autoloader
require './vendor/autoload.php';

use seregazhuk\Favro\Favro;

$favro = Favro::create('test@example.com', 'test');

// set your organization
$favro->useOrganization("My Organization");

// get all collections
$result = $favro->collections->getAll();

您可以获取所有组织,然后通过ID设置它

// get your organizations
$result = $favro->organizations->getAll();
$organizations = $result['entities'];

// select the first organization
$favro->useOrganization($organizations[0]['organizationId']);

速率限制

要获取当前的速率限制信息,请使用getRateInfo()方法

$result = $favro->getRateInfo();
print_r($result);

/*
[
    'reset' => 2016-09-03T08:17:24.158Z
    'remaining' => 42
    'limit' => 50
]
*/

结果将是包含三个元素的数组

关于速率限制的更多信息可以在官方API文档中找到。

用户

获取所有用户

$result = $favro->users->getAll();

响应将是用户数组

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
            "userId": "67973f72db34592d8fc96c48",
            "name": "Favro user",
            "email": "user@favro.com"
        ]
    ]
]

获取一个用户

参数

$result = $favro->users->getById($userId);

响应返回一个用户对象

[
    "userId": "67973f72db34592d8fc96c48",
    "name": "Favro user",
    "email": "user@favro.com"
]

组织

获取所有组织

$result = $favro->organizations->getAll();

响应将是组织数组

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
            "organizationId" : "67973f72db34592d8fc96c48",
            "name" : "My organization",
            "sharedToUsers": [
                [
                    "userId" : "fB6bJr5TbaKLiofns",
                    "role" : "administrator",
                    "joinDate" : "2016-02-10T14:25:58.745Z"
                ]
            ]
        ]
    ]
]

获取一个组织

参数

$result = $favro->organizations->getById($ogranizationId);

响应返回一个组织对象

[
    "organizationId" : "67973f72db34592d8fc96c48",
    "name" : "My organization",
    "sharedToUsers": [
        [
            "userId" : "fB6bJr5TbaKLiofns",
            "role" : "administrator",
            "joinDate" : "2016-02-10T14:25:58.745Z"
        ]
    ]
]

创建一个组织

参数$attributes是一个数组,包含以下值

shareToUsers也是一个具有以下结构的数组

$result = $favro->organizations->create($attributes);

响应将是创建的组织

[
    "organizationId" : "67973f72db34592d8fc96c48",
    "name" : "My organization",
    "sharedToUsers": [
        [
            "userId" : "fB6bJr5TbaKLiofns",
            "role" : "administrator",
            "joinDate" : "2016-02-10T14:25:58.745Z"
        ]
    ]
]

更新一个组织

参数

attributes是一个具有以下结构的数组

shareToUsers也是一个具有以下结构的数组

$result = $favro->organizations->update($organizationId, $attributes);

响应将是更新的组织

[
        "organizationId" : "67973f72db34592d8fc96c48",
        "name" : "My organization",
        "sharedToUsers": [
            [
                "userId" : "fB6bJr5TbaKLiofns",
                "role" : "administrator",
                "joinDate" : "2016-02-10T14:25:58.745Z"
            ]
        ]
]

集合

获取所有集合

$result = $favro->collections->getAll();

响应将是集合的分页列表

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [      
            "collectionId": "67973f72db34592d8fc96c48",
            "organizationId": "zk4CJpg5uozhL4R2W",
            "name": "My collection",
            "sharedToUsers": [
                [
                    "userId": "ff440e8f358c08513a86c8d6",
                    "role": "admin"
                ]
            ],
            "publicSharing": "users",
            "background": "purple",
            "archived": false,
            "shareWidgetsByDefault": true
        ]
    ]
]

获取一个集合

参数

$result = $favro->collections->getById($collectionId);

响应返回一个集合对象

[
    "collectionId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "name": "My collection",
    "sharedToUsers": [
        [
            "userId": "ff440e8f358c08513a86c8d6",
            "role": "admin"
        ]
    ],
    "publicSharing": "users",
    "background": "purple",
    "archived": false,
    "shareWidgetsByDefault": true
]

创建一个集合

参数$attributes是一个数组,包含以下值

shareToUsers也是一个具有以下结构的数组

$result = $favro->collections->create($attributes);

响应将是创建的集合

[
    "collectionId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "name": "My collection",
    "sharedToUsers": [
        [
            "userId": "ff440e8f358c08513a86c8d6",
            "role": "admin"
        ]
    ],
    "publicSharing": "users",
    "background": "purple",
    "archived": false,
    "shareWidgetsByDefault": true
]

更新一个集合

参数

attributes是一个具有以下结构的数组

shareToUsers也是一个具有以下结构的数组

$result = $favro->collections->update($collectionId, $attributes);

响应将是更新的集合

[
    "collectionId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "name": "My collection",
    "sharedToUsers": [
        [
            "userId": "ff440e8f358c08513a86c8d6",
            "role": "admin"
        ]
    ],
    "publicSharing": "users",
    "background": "purple",
    "archived": false,
    "shareWidgetsByDefault": true
]

删除一个集合

参数

$result = $favro->collections->delete($collectionId);

小部件

获取所有小部件

参数

$result = $favro->widgets->getAll();

响应将是分页的小部件数组

[
     "limit": 100,
     "page": 0,
     "pages": 1,
     "requestId": "8cc57b1d8a218fa639c8a0fa",
     "entities": [
        [
             "widgetCommonId": "67973f72db34592d8fc96c48",
             "organizationId": "zk4CJpg5uozhL4R2W",
             "collectionIds": [
                 "8cc57b1d8a218fa639c8a0fa"
             ],
             "name": "This is a widget",
             "type": "board",
             "publicSharing": "collection",
             "color": "purple",
             "sharedToUsers": [
                [
                    "userId": "tXfWe3MXQqhnnTRtw",
                    "role": "view"
                ]
             ]
         ]
     ]
 ]

获取一个小部件

参数

$result = $favro->widgets->getById($widgetCommonId);

响应返回一个小部件对象

[
    "widgetCommonId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "collectionIds": [
        "8cc57b1d8a218fa639c8a0fa"
    ],
    "name": "This is a widget",
    "type": "board",
    "publicSharing": "collection",
    "color": "purple",
    "sharedToUsers": [
        [
            "userId": "tXfWe3MXQqhnnTRtw",
            "role": "view"
        ]
    ]
]

创建一个小部件

参数$attributes是一个数组,包含以下值

shareToUsers也是一个具有以下结构的数组

$result = $favro->widgets->create($attributes); 

响应将是创建的小部件

[
    "widgetCommonId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "collectionIds": [
        "8cc57b1d8a218fa639c8a0fa"
    ],
    "name": "This is a widget",
    "type": "board",
    "publicSharing": "collection",
    "color": "purple",
    "sharedToUsers": [
        [
            "userId": "tXfWe3MXQqhnnTRtw",
            "role": "view"
        ]
    ]
]

更新一个小部件

参数

attributes是一个具有以下结构的数组

shareToUsers也是一个具有以下结构的数组

$result = $favro->widgets->update($widgetCommonId, $attributes);

响应将是更新的小部件

[
        "widgetCommonId": "67973f72db34592d8fc96c48",
        "organizationId": "zk4CJpg5uozhL4R2W",
        "collectionIds": [
            "8cc57b1d8a218fa639c8a0fa"
        ],
        "name": "This is a widget",
        "type": "board",
        "publicSharing": "collection",
        "color": "purple",
        "sharedToUsers": [
            [
                "userId": "tXfWe3MXQqhnnTRtw",
                "role": "view"
            ]
        ]
]

删除一个小部件

参数

$favro->widgets->delete($widgetCommonId);

// or

$favro->widgets->delete($widgetCommonId, $collectionId);

获取所有列

参数

$result = $favro->columns->getAll($widgetCommonId);

响应将是分页的列数组

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
        "columnId": "67973f72db34592d8fc96c48",
            "organizationId": "zk4CJpg5uozhL4R2W",
            "widgetCommonId": "ff440e8f358c08513a86c8d6",
            "name": "This is a column",
            "position": 0
        ]
    ]
]

获取一列

参数

$result = $favro->columns->getById($columnId);

响应返回一列对象

[
    "columnId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "widgetCommonId": "ff440e8f358c08513a86c8d6",
    "name": "This is a column",
    "position": 0
]

创建一列

参数$attributes是一个数组,包含以下值

$result = $favro->columns->create($attributes); 

响应将是创建的列

[
    "columnId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "widgetCommonId": "ff440e8f358c08513a86c8d6",
    "name": "This is a column",
    "position": 0
]

更新一列

参数

attributes是一个具有以下结构的数组

$result = $favro->columns->update($columnId, $attributes);

响应将是更新的列

[
    "columnId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "widgetCommonId": "ff440e8f358c08513a86c8d6",
    "name": "This is a column",
    "position": 0
]

删除一列

删除列将同时删除该列中存在的任何卡片。

参数

$result = $favro->columns->delete($columnId);

卡片

获取所有卡片

为了使用此端点,您必须指定todoList或cardCommonId、widgetCommonId或collectionId之一。

参数

$result = $favro->cards->getAll($params);

响应将是卡片的分页数组

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
        "cardId": "67973f72db34592d8fc96c48",
            "organizationId": "zk4CJpg5uozhL4R2W",
            "widgetCommonId": "ff440e8f358c08513a86c8d6",
            "columnId": "b4d8c6283d9d58f9a39108e7",
            "name": "This is a card"
        ]
    ]
]

获取一个卡片

参数

$result = $favro->cards->get($cardId);

响应返回一个卡片对象

[
    "cardId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "widgetCommonId": "ff440e8f358c08513a86c8d6",
    "columnId": "b4d8c6283d9d58f9a39108e7",
    "name": "This is a card"
]

创建一个卡片

参数$attributes是一个数组,包含以下值

$result = $favro->cards->create($attributes); 

响应将是创建的卡片

[
    "cardId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "widgetCommonId": "ff440e8f358c08513a86c8d6",
    "columnId": "b4d8c6283d9d58f9a39108e7",
    "name": "This is a card"
]

更新一个卡片

参数

attributes是一个具有以下结构的数组

$result = $favro->cards->update($cardId, $attributes);

响应将包含更新后的卡片

[
    "cardId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "widgetCommonId": "ff440e8f358c08513a86c8d6",
    "columnId": "b4d8c6283d9d58f9a39108e7",
    "name": "This is a card"
]

删除一张卡片

参数

$result = $favro->cards->delete($cardId, $everyWhere);

响应将返回被删除的卡片ID数组

[
    "67973f72db34592d8fc96c48",
    "67973f72db34592d8fc96c49",
    "67973f72db34592d8fc96c50"
]

标签

获取所有标签

参数

$result = $favro->tags->getAll($params);

响应将包含分页的标签数组

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
            "tagId": "67973f72db34592d8fc96c48",
            "organizationId": "zk4CJpg5uozhL4R2W",
            "name": "My tag",
            "color": "purple"
        ]
    ]
]

获取一个标签

$result = $favro->tags->get($tagId);

响应将返回标签对象

[
        "tagId": "67973f72db34592d8fc96c48",
        "organizationId": "zk4CJpg5uozhL4R2W",
        "name": "My tag",
        "color": "purple"
]

创建一个标签

参数$attributes是一个数组,包含以下值

$result = $favro->tags->create($attributes); 

响应将包含创建的标签

[
    "tagId": "67973f72db34592d8fc96c48",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "name": "My tag",
    "color": "purple"
]

更新一个标签

attributes是一个具有以下结构的数组

$result = $favro->tags->update($tagId, $attributes);

响应将包含更新的标签

[
     "tagId": "67973f72db34592d8fc96c48",
     "organizationId": "zk4CJpg5uozhL4R2W",
     "name": "My tag",
     "color": "purple"
]

删除一个标签

参数

$result = $favro->tags->delete($tagId);

任务

获取所有任务

参数

$result = $favro->tasks->getAll($params);

响应将包含分页的卡片任务数组

[  "limit": 100,
     "page": 0,
     "pages": 1,
     "requestId": "8cc57b1d8a218fa639c8a0fa",
     "entities": [
        [
             "taskId": "67973f72db34592d8fc96c48",
             "taskListId": "8cc57b1d8a218fa639c8a0fa",
             "organizationId": "zk4CJpg5uozhL4R2W",
             "cardCommonId": "tXfWe3MXQqhnnTRtw",
             "name": "This is a task",
             "completed": false,
             "position": 0
        ]
     ]
 ]

获取一个任务

$result = $favro->tasks->get($taskId);

响应将返回任务对象

[
    "taskId": "67973f72db34592d8fc96c48",
    "taskListId": "8cc57b1d8a218fa639c8a0fa",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "cardCommonId": "tXfWe3MXQqhnnTRtw",
    "name": "This is a task",
    "completed": false,
    "position": 0
]

创建一个任务

参数$attributes是一个数组,包含以下值

$result = $favro->tasks->create($attributes); 

响应将包含创建的任务

[
    "taskId": "67973f72db34592d8fc96c48",
    "taskListId": "8cc57b1d8a218fa639c8a0fa",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "cardCommonId": "tXfWe3MXQqhnnTRtw",
    "name": "This is a task",
    "completed": false,
    "position": 0
]

更新一个任务

attributes是一个具有以下结构的数组

$result = $favro->tasks->update($taskId, $attributes); 

响应将包含更新的任务

[
    "taskId": "67973f72db34592d8fc96c48",
    "taskListId": "8cc57b1d8a218fa639c8a0fa",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "cardCommonId": "tXfWe3MXQqhnnTRtw",
    "name": "This is a task",
    "completed": false,
    "position": 0
]

删除一个任务

参数

$result = $favro->tasks->delete($taskId);

任务列表

获取所有任务列表

参数

$result = $favro->tasklists->getAll($cardCommonId);

响应将包含分页的卡片任务列表数组

[
    "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
            "taskListId": "8cc57b1d8a218fa639c8a0fa",
            "organizationId": "zk4CJpg5uozhL4R2W",
            "cardCommonId": "tXfWe3MXQqhnnTRtw",
            "description": "This is a tasklist",
            "position": 0
        ]
    ]
]

获取一个任务列表

$result = $favro->tasklists->get($taskListId);

响应将返回任务列表对象

[
    "taskListId": "8cc57b1d8a218fa639c8a0fa",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "cardCommonId": "tXfWe3MXQqhnnTRtw",
    "description": "This is a tasklist",
    "position": 0
]

创建一个任务列表

参数$attributes是一个数组,包含以下值

$result = $favro->tasklists->create($attributes); 

响应将包含创建的任务列表

[
    "taskListId": "8cc57b1d8a218fa639c8a0fa",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "cardCommonId": "tXfWe3MXQqhnnTRtw",
    "description": "This is a tasklist",
    "position": 0
]

更新一个任务列表

attributes是一个具有以下结构的数组

$result = $favro->tasklists->update($taskListId, $attributes); 

响应将包含更新的任务

[
    "taskListId": "8cc57b1d8a218fa639c8a0fa",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "cardCommonId": "tXfWe3MXQqhnnTRtw",
    "description": "This is a tasklist",
    "position": 0
]

删除一个任务列表

参数

$result = $favro->tasklists->delete($taskListId);

评论

获取所有评论

参数

$result = $favro->comments->getAll($cardCommonId);

响应将包含分页的评论数组

  "limit": 100,
    "page": 0,
    "pages": 1,
    "requestId": "8cc57b1d8a218fa639c8a0fa",
    "entities": [
        [
        "commentId": "67973f72db34592d8fc96c48",
            "cardCommonId": "ff440e8f358c08513a86c8d6",
            "organizationId": "zk4CJpg5uozhL4R2W",
            "userId": "b4d8c6283d9d58f9a39108e7",
            "comment": "This is a comment",
            "created": "2016-04-18T11:18:42.901Z",
            "lastUpdated": "2016-04-18T11:18:42.901Z"
        ]
    ]

获取一条评论

$result = $favro->comments->get($commentId);

响应将返回评论对象

[
    "commentId": "67973f72db34592d8fc96c48",
    "cardCommonId": "ff440e8f358c08513a86c8d6",
    "organizationId": "zk4CJpg5uozhL4R2W",
    "userId": "b4d8c6283d9d58f9a39108e7",
    "comment": "This is a comment",
    "created": "2016-04-18T11:18:42.901Z",
    "lastUpdated": "2016-04-18T11:18:42.901Z"
]

创建一条评论

我该如何感谢你呢?

为什么不给GitHub仓库点个赞呢?我很希望得到关注!

谢谢!