seregazhuk / favro-api
A PHP wrapper for the official Favro API
Installs: 10 165
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 7
Open Issues: 2
Type:package
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mockery/mockery: ^0.9.5
- phpunit/phpunit: ~5.7
This package is auto-updated.
Last update: 2024-12-16 04:28:48 UTC
README
- Dependencies
- Installation
- Quick Start
- Rate limiting
- Users
- Organizations
- Collections
- Widgets
- Columns
- Cards
- Tags
- Tasks
- Tasklists
- Comments
Dependencies
Library requires CURL extension and PHP 5.6 or above.
Installation
The recommended way to install this library is via Composer. New to Composer?
composer require seregazhuk/favro-api
Quick Start
First of all you need to select your current organization, because nearly all API requests require the organizationId of the organization that these call are being made against. You can set your current organization in two ways: by name or by 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();
You can get all your organization and then set it by id:
// get your organizations $result = $favro->organizations->getAll(); $organizations = $result['entities']; // select the first organization $favro->useOrganization($organizations[0]['organizationId']);
Rate limiting
To get your current rate limit information use getRateInfo() method:
$result = $favro->getRateInfo(); print_r($result); /* [ 'reset' => 2016-09-03T08:17:24.158Z 'remaining' => 42 'limit' => 50 ] */
Result will be an array of three elements:
More information about rate limiting is available in the official api docs.
Users
Get all users
$result = $favro->users->getAll();
The response will be an array of users:
[ "limit": 100, "page": 0, "pages": 1, "requestId": "8cc57b1d8a218fa639c8a0fa", "entities": [ [ "userId": "67973f72db34592d8fc96c48", "name": "Favro user", "email": "user@favro.com" ] ] ]
Get a user
Arguments:
$result = $favro->users->getById($userId);
The response returns a user object:
[ "userId": "67973f72db34592d8fc96c48", "name": "Favro user", "email": "user@favro.com" ]
Organizations
Get all organizations
$result = $favro->organizations->getAll();
The response will be an array of organizations:
[ "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" ] ] ] ] ]
Get an organization
Arguments:
$result = $favro->organizations->getById($ogranizationId);
The response returns an organization object:
[ "organizationId" : "67973f72db34592d8fc96c48", "name" : "My organization", "sharedToUsers": [ [ "userId" : "fB6bJr5TbaKLiofns", "role" : "administrator", "joinDate" : "2016-02-10T14:25:58.745Z" ] ] ]
Create an organization
Argument $attributes
is an array and contains the following values:
shareToUsers
is also an array with the following structure:
$result = $favro->organizations->create($attributes);
The response will be the created organization:
[ "organizationId" : "67973f72db34592d8fc96c48", "name" : "My organization", "sharedToUsers": [ [ "userId" : "fB6bJr5TbaKLiofns", "role" : "administrator", "joinDate" : "2016-02-10T14:25:58.745Z" ] ] ]
Update an organization
Arguments:
attributes
is an array with the following structure:
shareToUsers
is also an array with the following structure:
$result = $favro->organizations->update($organizationId, $attributes);
The response will be the updated organization:
[ "organizationId" : "67973f72db34592d8fc96c48", "name" : "My organization", "sharedToUsers": [ [ "userId" : "fB6bJr5TbaKLiofns", "role" : "administrator", "joinDate" : "2016-02-10T14:25:58.745Z" ] ] ]
Collections
Get all collections
$result = $favro->collections->getAll();
The response will be a paginated list of collections:
[ "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 ] ] ]
Get an collection
Arguments:
$result = $favro->collections->getById($collectionId);
The response returns a collection object:
[
"collectionId": "67973f72db34592d8fc96c48",
"organizationId": "zk4CJpg5uozhL4R2W",
"name": "My collection",
"sharedToUsers": [
[
"userId": "ff440e8f358c08513a86c8d6",
"role": "admin"
]
],
"publicSharing": "users",
"background": "purple",
"archived": false,
"shareWidgetsByDefault": true
]
Create a collection
Argument $attributes
is an array and contains the following values:
shareToUsers
is also an array with the following structure:
$result = $favro->collections->create($attributes);
The response will be the created collection:
[
"collectionId": "67973f72db34592d8fc96c48",
"organizationId": "zk4CJpg5uozhL4R2W",
"name": "My collection",
"sharedToUsers": [
[
"userId": "ff440e8f358c08513a86c8d6",
"role": "admin"
]
],
"publicSharing": "users",
"background": "purple",
"archived": false,
"shareWidgetsByDefault": true
]
Update a collection
Arguments:
attributes
is an array with the following structure:
shareToUsers
is also an array with the following structure:
$result = $favro->collections->update($collectionId, $attributes);
The response will be the updated collection:
[ "collectionId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "name": "My collection", "sharedToUsers": [ [ "userId": "ff440e8f358c08513a86c8d6", "role": "admin" ] ], "publicSharing": "users", "background": "purple", "archived": false, "shareWidgetsByDefault": true ]
Delete a collection
Arguments:
$result = $favro->collections->delete($collectionId);
Widgets
Get all widgets
Arguments:
$result = $favro->widgets->getAll();
The response will be a paginated array of widgets:
[ "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" ] ] ] ] ]
Get a widget
Arguments:
$result = $favro->widgets->getById($widgetCommonId);
The response returns a widget object:
[ "widgetCommonId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "collectionIds": [ "8cc57b1d8a218fa639c8a0fa" ], "name": "This is a widget", "type": "board", "publicSharing": "collection", "color": "purple", "sharedToUsers": [ [ "userId": "tXfWe3MXQqhnnTRtw", "role": "view" ] ] ]
Argument $attributes
is an array and contains the following values:
shareToUsers
is also an array with the following structure:
$result = $favro->widgets->create($attributes);
The response will be the created widget:
[ "widgetCommonId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "collectionIds": [ "8cc57b1d8a218fa639c8a0fa" ], "name": "This is a widget", "type": "board", "publicSharing": "collection", "color": "purple", "sharedToUsers": [ [ "userId": "tXfWe3MXQqhnnTRtw", "role": "view" ] ] ]
Update a widget
Arguments:
attributes
is an array with the following structure:
shareToUsers
is also an array with the following structure:
$result = $favro->widgets->update($widgetCommonId, $attributes);
The response will be the updated widget:
[ "widgetCommonId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "collectionIds": [ "8cc57b1d8a218fa639c8a0fa" ], "name": "This is a widget", "type": "board", "publicSharing": "collection", "color": "purple", "sharedToUsers": [ [ "userId": "tXfWe3MXQqhnnTRtw", "role": "view" ] ] ]
Delete a widget
Arguments:
$favro->widgets->delete($widgetCommonId); // or $favro->widgets->delete($widgetCommonId, $collectionId);
Columns
Get all columns
Arguments:
$result = $favro->columns->getAll($widgetCommonId);
The response will be a paginated array of columns:
[ "limit": 100, "page": 0, "pages": 1, "requestId": "8cc57b1d8a218fa639c8a0fa", "entities": [ [ "columnId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "name": "This is a column", "position": 0 ] ] ]
Get a column
Arguments:
$result = $favro->columns->getById($columnId);
The response returns a column object:
[ "columnId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "name": "This is a column", "position": 0 ]
Create a column
Argument $attributes
is an array and contains the following values:
$result = $favro->columns->create($attributes);
The response will be the created column:
[ "columnId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "name": "This is a column", "position": 0 ]
Update a column
Arguments:
attributes
is an array with the following structure:
$result = $favro->columns->update($columnId, $attributes);
The response will be the updated column:
[ "columnId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "name": "This is a column", "position": 0 ]
Delete a column
Deleting a column will also delete any cards that exist within that column.
Arguments:
$result = $favro->columns->delete($columnId);
Cards
Get Get all cards
In order to use this endpoint you must specify either todoList or one of cardCommonId, widgetCommonId or collectionId.
Arguments:
$result = $favro->cards->getAll($params);
The response will be a paginated array of cards:
[ "limit": 100, "page": 0, "pages": 1, "requestId": "8cc57b1d8a218fa639c8a0fa", "entities": [ [ "cardId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "columnId": "b4d8c6283d9d58f9a39108e7", "name": "This is a card" ] ] ]
Get a card
Arguments:
$result = $favro->cards->get($cardId);
The response returns a card object:
[ "cardId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "columnId": "b4d8c6283d9d58f9a39108e7", "name": "This is a card" ]
Create a card
Argument $attributes
is an array and contains the following values:
$result = $favro->cards->create($attributes);
The response will be the created card:
[ "cardId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "columnId": "b4d8c6283d9d58f9a39108e7", "name": "This is a card" ]
Update a card
Arguments:
attributes
is an array with the following structure:
$result = $favro->cards->update($cardId, $attributes);
The response will be the updated cards:
[ "cardId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "widgetCommonId": "ff440e8f358c08513a86c8d6", "columnId": "b4d8c6283d9d58f9a39108e7", "name": "This is a card" ]
Delete a card
Arguments:
$result = $favro->cards->delete($cardId, $everyWhere);
The response returns an array of cardIds for the cards that were deleted.
[ "67973f72db34592d8fc96c48", "67973f72db34592d8fc96c49", "67973f72db34592d8fc96c50" ]
Tags
Get all tags
Arguments:
$result = $favro->tags->getAll($params);
The response will be a paginated array of tags:
[ "limit": 100, "page": 0, "pages": 1, "requestId": "8cc57b1d8a218fa639c8a0fa", "entities": [ [ "tagId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "name": "My tag", "color": "purple" ] ] ]
Get a tag
$result = $favro->tags->get($tagId);
The response returns a tag object:
[ "tagId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "name": "My tag", "color": "purple" ]
Create a tag
Argument $attributes
is an array and contains the following values:
$result = $favro->tags->create($attributes);
The response will be the created tag:
[ "tagId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "name": "My tag", "color": "purple" ]
Update a tag
attributes
is an array with the following structure:
$result = $favro->tags->update($tagId, $attributes);
The response will be the updated tag:
[ "tagId": "67973f72db34592d8fc96c48", "organizationId": "zk4CJpg5uozhL4R2W", "name": "My tag", "color": "purple" ]
Delete a tag
Arguments:
$result = $favro->tags->delete($tagId);
Tasks
Get all tasks
Arguments:
$result = $favro->tasks->getAll($params);
The response will be a paginated array of card tasks:
[ "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 ] ] ]
Get a task
$result = $favro->tasks->get($taskId);
The response returns a task object:
[ "taskId": "67973f72db34592d8fc96c48", "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "name": "This is a task", "completed": false, "position": 0 ]
Create a task
Argument $attributes
is an array and contains the following values:
$result = $favro->tasks->create($attributes);
The response will be the created task:
[ "taskId": "67973f72db34592d8fc96c48", "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "name": "This is a task", "completed": false, "position": 0 ]
Update a task
attributes
is an array with the following structure:
$result = $favro->tasks->update($taskId, $attributes);
The response will be the updated task:
[ "taskId": "67973f72db34592d8fc96c48", "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "name": "This is a task", "completed": false, "position": 0 ]
Delete a task
Arguments:
$result = $favro->tasks->delete($taskId);
Tasklists
Get all tasklists
Arguments:
$result = $favro->tasklists->getAll($cardCommonId);
The response will be a paginated array of card task lists:
[ "limit": 100, "page": 0, "pages": 1, "requestId": "8cc57b1d8a218fa639c8a0fa", "entities": [ [ "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "description": "This is a tasklist", "position": 0 ] ] ]
Get a task list
$result = $favro->tasklists->get($taskListId);
The response returns a task list object:
[ "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "description": "This is a tasklist", "position": 0 ]
Create a task list
Argument $attributes
is an array and contains the following values:
$result = $favro->tasklists->create($attributes);
The response will be the created task list:
[ "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "description": "This is a tasklist", "position": 0 ]
Update a task list
attributes
is an array with the following structure:
$result = $favro->tasklists->update($taskListId, $attributes);
The response will be the updated task:
[ "taskListId": "8cc57b1d8a218fa639c8a0fa", "organizationId": "zk4CJpg5uozhL4R2W", "cardCommonId": "tXfWe3MXQqhnnTRtw", "description": "This is a tasklist", "position": 0 ]
Delete a task list
Arguments:
$result = $favro->tasklists->delete($taskListId);
Comments
Get all comments
Arguments:
$result = $favro->comments->getAll($cardCommonId);
The response will be a paginated array of comments:
"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" ] ]
Get a comment
$result = $favro->comments->get($commentId);
The response returns a comment object:
[ "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" ]
Create a comment
How can I thank you?
Why not star the github repo? I'd love the attention!
Thanks!