A PHP Laravel wrapper library for Teamwork Desk, Teamwork Help Docs and Teamwork Tickets API's.
This package was built for our internal projects and may not be the right one for you but you are free to use it if you like.
You can install the package via composer:
composer require digitalequation/teamworkRun the package install command:
php artisan teamwork:installThis will publish and register the TeamworkServiceProvider and will also generate a config file config/teamwork.php.
return [
'desk' => [
/*
|--------------------------------------------------------------------------
| Teamwork Desk Key
|--------------------------------------------------------------------------
|
| The Teamwork Desk API Key can be generated at:
| https://your-domain.teamwork.com/desk/#myprofile/apikeys
|
*/
'key' => env('TEAMWORK_DESK_KEY'),
/*
|--------------------------------------------------------------------------
| Teamwork Desk Domain Name
|--------------------------------------------------------------------------
|
| The domain is the site address you have set on the Teamwork account.
| To find the domain name just login to http://teamwork.com.
| Then you will see the browser URL changing to:
| https://your-domain.teamwork.com/launchpad/welcome
|
*/
'domain' => env('TEAMWORK_DESK_DOMAIN'),
],
];You can edit this file directly but we recommend to add your settings in the .env file.
If you edit the config file and want to restore the defaults run:
php artisan teamwork:publishAdd your Teamwork Desk API Key and Domain to the .env file:
TEAMWORK_DESK_KEY=--YOUR-TEAMWORK-DESK-KEY--
TEAMWORK_DESK_DOMAIN=--YOUR-TEAMWORK-DESK-DOMAIN--Example using facade:
use Teamwork;
$response = Teamwork::desk()->me();Example using dependency injection:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DigitalEquation\Teamwork\Teamwork;
class TeamworkController extends Controller
{
protected $teamwork;
public function __construct(Teamwork $teamwork)
{
$this->teamwork = $teamwork;
}
public function getMe()
{
try {
$response = $this->teamwork->desk()->me();
// do something with the response data...
} catch (\Exception $e) {
// do something with the error...
}
}
// other methodsFor all of the examples listed bellow we will use the Teamwork facade.
Get current user data:
$response = Teamwork::desk()->me();Get all Teamwork Desk Inboxes:
$response = Teamwork::desk()->inboxes();Get an inbox by name:
$response = Teamwork::desk()->inbox('Inbox Name');Upload a file:
$teamworkUser = Teamwork::desk()->me();
$response = Teamwork::desk()->upload($teamworkUser['id'], $request->file);Example response for file upload:
[
'id' => 1312, // the uploaded file id on Teamwork
'url' => 'http://...', // the URL of the image
'extension' => 'jpg',
'name' => 'Some File Name',
'size' => '42342', // the image size in kb
]TIP: Surround your Teamwork calls in try-catch blocks to capture any possible thrown exception.
Get ticket priorities:
$response = Teamwork::tickets()->priorities();Get a ticket by id:
$response = Teamwork::tickets()->ticket($ticketId);Get a list of tickets for a customer/user:
$response = Teamwork::tickets()->customer($customerId);Post/Send a ticket:
$data = [
'assignedTo' => 5465, // the id of the assigned user on ticket
'inboxId' => 5545, // the inbox id where the ticket will be sent
'tags' => 'Test ticket',
'priority' => 'low',
'status' => 'active',
'source' => 'Email (Manual)',
'customerFirstName' => 'Test', // sender's first name
'customerLastName' => 'User', // sender's last name
'customerEmail' => 'test.user@email.com', // sender's email
'customerPhoneNumber' => '', // sender's phone number
'subject' => 'Ticket Subject',
'previewTest' => 'Ticket excerpt.',
'message' => 'The ticket body...',
];
$response = Teamwork::tickets()->post($data);Reply to a ticket:
$data = [
'ticketId' => 2201568, // the ticket id where the reply will be sent
'body' => 'Reply TEST on ticket.',
'customerId' => 65465,
];
$response = Teamwork::tickets()->reply($data);Get Help Docs list of sites:
$response = Teamwork::helpDesk()->getSites();Get a Help Docs site by id:
$response = Teamwork::helpDesk()->getSite($siteId);Get all categories within a site:
$response = Teamwork::helpDesk()->getSitesCategories($siteId);Get articles within a category:
$response = Teamwork::helpDesk()->getCategoryArticles($categoryId, $pageId);Get a list of site articles:
$response = Teamwork::helpDesk()->getSiteArticles($siteId, $pageId);Get a single article:
$response = Teamwork::helpDesk()->getArticle($articleId);Get multiple articles by id's:
$response = Teamwork::helpDesk()->getArticles($articleIDs);composer testThis will also generate a coverage report that is accessible on the build directory, coverage and open the index.html file to see the results.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email robert@thebug.ro instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.